Skip to content
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

Esbuild logging error upon SIGINT #3480

Closed
JoshuaWise opened this issue Nov 8, 2023 · 2 comments
Closed

Esbuild logging error upon SIGINT #3480

JoshuaWise opened this issue Nov 8, 2023 · 2 comments

Comments

@JoshuaWise
Copy link

JoshuaWise commented Nov 8, 2023

Hi, this is continuation of #3219. I noticed that although the original unhandledRejection is fixed, esbuild is still logging an error upon SIGINT. Using the same script as in #3219 (comment), I now get the following output:

building...
^CSIGINT detected
Error caught: Error: The service was stopped
    at /Users/josh/code/projects/super-server/node_modules/esbuild/lib/main.js:1083:25
    at responseCallbacks.<computed> (/Users/josh/code/projects/super-server/node_modules/esbuild/lib/main.js:703:9)
    at Socket.afterClose (/Users/josh/code/projects/super-server/node_modules/esbuild/lib/main.js:693:28)
    at Socket.emit (node:events:526:35)
    at endReadableNT (node:internal/streams/readable:1408:12)
    at process.processTicksAndRejections (node:internal/process/task_queues:82:21)

I'm using logLevel: "silent", so esbuild really shouldn't be logging things without me asking for it. In my application, the expected behavior when the user cancels a build (via SIGINT) is for there to be no output, but I can't achieve this due to esbuild logging this error without my consent. I don't want the error to be displayed to the user.

@evanw
Copy link
Owner

evanw commented Dec 19, 2023

This doesn't seem like a bug. You are logging this, not esbuild, so esbuild's log level is irrelevant. Your source code contains this:

main().catch((err) => {
  console.log('Error caught:', err);
});

And the logs you posted contain this:

Error caught: Error: The service was stopped

The log starts with Error caught: which is the string from your source code. If you don't want this error to be logged, then you should not have your code log the error. The following patch adjusts the script in #3219 (comment) to not log the error:

 main().catch((err) => {
-  console.log('Error caught:', err);
+  // console.log('Error caught:', err);
 });

I'm closing this issue as this log message does not originate from within esbuild.

@evanw evanw closed this as not planned Won't fix, can't repro, duplicate, stale Dec 19, 2023
@JoshuaWise
Copy link
Author

Whoops! My mistake. Sorry for invalid issue!

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

No branches or pull requests

2 participants