Skip to content

fix: Return bearer middleware result instead of awaiting#1049

Merged
AdiRishi merged 2 commits intomasterfrom
fix/1045-hono-middeware
Jan 19, 2026
Merged

fix: Return bearer middleware result instead of awaiting#1049
AdiRishi merged 2 commits intomasterfrom
fix/1045-hono-middeware

Conversation

@AdiRishi
Copy link
Copy Markdown
Owner

  • Fix bearerAuth middleware usage in internal and artifacts routes by returning the middleware result instead of just awaiting it
  • Add vitest packages to renovate ignore list to sync with .ncurc.json

Fixes #1045

- Fix bearerAuth middleware usage in internal and artifacts routes by
returning the middleware result instead of just awaiting it
- Add vitest packages to renovate ignore list to sync with .ncurc.json
@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Jan 19, 2026

🦋 Changeset detected

Latest commit: 9f57963

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
turborepo-remote-cache-cf Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Jan 19, 2026

Walkthrough

Return middleware functions directly instead of awaiting them in two route handlers to ensure the middleware promise is propagated to the caller, fixing worker promise handling errors.

Changes

Cohort / File(s) Summary
Middleware return pattern fixes
src/routes/internal.ts, src/routes/v8/artifacts.ts
Replaced await middleware(c, next) with return middleware(c, next); renamed local variable to bearer; added ESLint disable comments for unsafe-argument usage.
Changeset
.changeset/gold-stamps-retire.md
Added changeset noting the fix (middleware return change).

Sequence Diagram

sequenceDiagram
    participant Worker
    participant Route
    participant Middleware

    rect rgba(255, 0, 0, 0.5)
    Note over Worker,Route: Old (Broken) Pattern
    Worker->>Route: Request
    Route->>Middleware: await middleware(c, next)
    Middleware-->>Route: Resolves
    Route-->>Worker: undefined
    Worker-xRoute: ❌ Error: Worker returned Promise
    end

    rect rgba(0, 255, 0, 0.5)
    Note over Worker,Route: New (Fixed) Pattern
    Worker->>Route: Request
    Route->>Middleware: return middleware(c, next)
    Middleware-->>Worker: Promise
    Worker->>Middleware: Awaits promise
    Middleware-->>Worker: ✅ Success
    end
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Poem

A rabbit hops and gives a cheer,
"Return the middleware, bring it near!" 🐇
No more stray promises in the night,
Routes now pass the promise right. ✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1
❌ Failed checks (1 inconclusive)
Check name Status Explanation Resolution
Out of Scope Changes check ❓ Inconclusive The PR includes a secondary change to add vitest packages to the renovate ignore list, which appears unrelated to the primary middleware fix from issue #1045. Clarify whether the renovate ignore list change is part of issue #1045 or should be addressed in a separate PR for better change isolation.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely summarizes the main change: returning the bearer middleware result instead of awaiting it.
Description check ✅ Passed The description covers the main changes, references the fixed issue (#1045), and includes an additional improvement (renovate ignore list update).
Linked Issues check ✅ Passed The PR successfully addresses issue #1045 by changing middleware calls from awaiting to returning in both internal.ts and artifacts.ts routes.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/1045-hono-middeware

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions
Copy link
Copy Markdown
Contributor

🌩 Deploying with Cloudflare Pages

Name Result
Last commit: b3dcc67
Status: ✅ Deploy successful!
Preview URL: https://6df9001c.cloudflare-turbo-cache-docs.pages.dev

@github-actions
Copy link
Copy Markdown
Contributor

🌩 Deploying with Cloudflare Pages

Name Result
Last commit: 9f57963
Status: ✅ Deploy successful!
Preview URL: https://46911c25.cloudflare-turbo-cache-docs.pages.dev

@AdiRishi AdiRishi merged commit ce7af83 into master Jan 19, 2026
7 checks passed
@AdiRishi AdiRishi deleted the fix/1045-hono-middeware branch January 19, 2026 06:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Middleware to be returned, not awaited

1 participant