New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update middleware eval checks #30883
Changes from 5 commits
fbf3f94
00c6c42
be2f558
1138e71
053bbe5
df5c5e2
21a04d9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -514,7 +514,13 @@ export default class DevServer extends Server { | |
parsed: UrlWithParsedQuery | ||
}): Promise<FetchEventResult | null> { | ||
try { | ||
const result = await super.runMiddleware(params) | ||
const result = await super.runMiddleware({ | ||
...params, | ||
onWarning: (warn) => { | ||
this.logErrorWithOriginalStack(warn, 'warning', 'client') | ||
}, | ||
}) | ||
|
||
result?.waitUntil.catch((error) => | ||
this.logErrorWithOriginalStack(error, 'unhandledRejection', 'client') | ||
) | ||
|
@@ -589,7 +595,7 @@ export default class DevServer extends Server { | |
|
||
private async logErrorWithOriginalStack( | ||
err?: unknown, | ||
type?: 'unhandledRejection' | 'uncaughtException', | ||
type?: 'unhandledRejection' | 'uncaughtException' | 'warning', | ||
stats: 'server' | 'client' = 'server' | ||
) { | ||
let usedOriginalStack = false | ||
|
@@ -630,11 +636,15 @@ export default class DevServer extends Server { | |
const { file, lineNumber, column, methodName } = originalStackFrame | ||
|
||
console.error( | ||
chalk.red('error') + | ||
(type === 'warning' ? chalk.yellow('warn') : chalk.red('error')) + | ||
' - ' + | ||
`${file} (${lineNumber}:${column}) @ ${methodName}` | ||
) | ||
console.error(`${chalk.red(err.name)}: ${err.message}`) | ||
console.error( | ||
`${(type === 'warning' ? chalk.yellow : chalk.red)(err.name)}: ${ | ||
err.message | ||
}` | ||
) | ||
console.error(originalCodeFrame) | ||
usedOriginalStack = true | ||
} | ||
|
@@ -647,7 +657,9 @@ export default class DevServer extends Server { | |
} | ||
|
||
if (!usedOriginalStack) { | ||
if (type) { | ||
if (type === 'warning') { | ||
Log.warn(err + '') | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why no "warning" prefix? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @styfle The prefix is added by |
||
} else if (type) { | ||
Log.error(`${type}:`, err + '') | ||
} else { | ||
Log.error(err + '') | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
export function getTextWithEval() { | ||
// eslint-disable-next-line no-eval | ||
return eval('with some text') | ||
} | ||
|
||
export function getText() { | ||
return 'with some text' | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this was recently changed to
any
but I don't remember whycc @timneutkens @sokra