Skip to content

How to disable warnings for unhandled requests #1589

Answered by kettanaito
arvindell asked this question in Q&A
Discussion options

You must be logged in to vote

Hi, @arvindell.

You can disable the unhandled request warning by providing the onUnhandledRequest option to worker.start()/server.listen()

server.listen({
  // This is going to perform unhandled requests
  // but print no warning whatsoever when they happen.
  onUnhandledRequest: 'bypass'
})

See the docs

Since this warning brings some DX value, I highly recommend you provide a function to onUnhandledRequest instead, where you will whitelist certain unhandled requests while still print the warning message on others.

server.listen({
  onUnhandledRequest(request, print) {
    // Do not print warnings on unhandled requests to Sentry.
    if (request.url.hostname.includes('sentry.io')) {

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
1 reply
@arvindell
Comment options

Answer selected by kettanaito
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants