Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 25 additions & 22 deletions packages/start-server-core/src/createStartHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -495,33 +495,36 @@ function executeMiddleware(middlewares: TODO, ctx: TODO) {
const middleware = middlewares[index]
if (!middleware) return ctx

const result = await middleware({
...ctx,
// Allow the middleware to call the next middleware in the chain
next: async (nextCtx: TODO) => {
// Allow the caller to extend the context for the next middleware
const nextResult = await next({
...ctx,
...nextCtx,
context: {
...ctx.context,
...(nextCtx?.context || {}),
},
})
let result
try {
result = await middleware({
...ctx,
// Allow the middleware to call the next middleware in the chain
next: async (nextCtx: TODO) => {
// Allow the caller to extend the context for the next middleware
const nextResult = await next({
...ctx,
...nextCtx,
context: {
...ctx.context,
...(nextCtx?.context || {}),
},
})

// Merge the result into the context\
return Object.assign(ctx, handleCtxResult(nextResult))
},
// Allow the middleware result to extend the return context
}).catch((err: TODO) => {
// Merge the result into the context\
return Object.assign(ctx, handleCtxResult(nextResult))
},
// Allow the middleware result to extend the return context
})
} catch (err: TODO) {
if (isSpecialResponse(err)) {
return {
result = {
response: err,
}
} else {
throw err
}

throw err
})
}
Comment on lines +519 to +527
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

Fix lint failure in catch clause

Biome reports “Catch clause variable type annotation must be 'any' or 'unknown'” for catch (err: TODO), which breaks lint and will block CI. Please swap the annotation to unknown (or remove it) so the pipeline passes.

-    } catch (err: TODO) {
+    } catch (err: unknown) {
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
} catch (err: TODO) {
if (isSpecialResponse(err)) {
return {
result = {
response: err,
}
} else {
throw err
}
throw err
})
}
} catch (err: unknown) {
if (isSpecialResponse(err)) {
result = {
response: err,
}
} else {
throw err
}
}
🧰 Tools
🪛 Biome (2.1.2)

[error] 519-519: Catch clause variable type annotation must be 'any' or 'unknown' if specified.

(parse)

🤖 Prompt for AI Agents
In packages/start-server-core/src/createStartHandler.ts around lines 519 to 527,
the catch clause currently uses an invalid annotation `catch (err: TODO)` which
triggers the Biome lint rule requiring catch variables be typed as 'any' or
'unknown'; change the annotation to `catch (err: unknown)` (or remove the type
entirely) so the catch variable complies with lint, then ensure subsequent uses
of `err` are narrowed (e.g., use type guards like isSpecialResponse(err)) or
properly asserted before treating it as a specific type.


// Merge the middleware result into the context, just in case it
// returns a partial context
Expand Down
Loading