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

Aggregate errors or errors with cause are not logged #17836

Open
steverep opened this issue Dec 2, 2023 · 3 comments
Open

Aggregate errors or errors with cause are not logged #17836

steverep opened this issue Dec 2, 2023 · 3 comments

Comments

@steverep
Copy link
Contributor

steverep commented Dec 2, 2023

Bug report

What is the current behavior?

If an AggregateError or Error with cause is thrown, Webpack intercepts and only logs the primary message. For these cases, that message is often just an annotation on the real error, making it impossible to debug them from a Webpack plugin.

If the current behavior is a bug, please provide the steps to reproduce.

Throw an instance of AggregateError or an instance of Error with a cause property from any plugin, and then just examine the console output.

What is the expected behavior?

  • For AggregateError, each of the errors should be logged
  • For Error with cause, the cause should be logged as well

Other relevant information:
webpack version: 5.89.0
Node.js version: 20
Operating System: Linux
Additional tools:

@dmitryrn
Copy link

I seem to have the same problem.

I tried the following in NestJS with nest start --watch:

    try {
      await this.createEventStream()
    } catch (error) {
      throw new Error('creating stream', { cause: error })
    }

In the terminal I see that the cause is not logged:

.../src/subscriber/subscriber.service.ts:44
      throw new Error('creating stream', { cause: error })
            ^
Error: creating stream
    at SubscriberService.onModuleInit (.../src/subscriber/subscriber.service.ts:44:13)
    at async Promise.all (index 1)
    at callModuleInitHook (.../node_modules/@nestjs/core/hooks/on-module-init.hook.js:43:5)
    at NestApplication.callInitHook (.../node_modules/@nestjs/core/nest-application-context.js:223:13)
    at NestApplication.init (.../node_modules/@nestjs/core/nest-application.js:100:9)
    at NestApplication.listen (.../node_modules/@nestjs/core/nest-application.js:169:33)
    at bootstrap (.../src/main.ts:18:3)

When I run nest build and then node dist/main, I have the expected stack trace:

.../dist/subscriber/subscriber.service.js:37
            throw new Error('creating stream', { cause: error });
                  ^

Error: creating stream
    at SubscriberService.onModuleInit (.../dist/subscriber/subscriber.service.js:37:19)
    at async Promise.all (index 1)
    at async callModuleInitHook (.../node_modules/@nestjs/core/hooks/on-module-init.hook.js:43:5)
    at async NestApplication.callInitHook (.../node_modules/@nestjs/core/nest-application-context.js:223:13)
    at async NestApplication.init (.../node_modules/@nestjs/core/nest-application.js:100:9)
    at async NestApplication.listen (.../node_modules/@nestjs/core/nest-application.js:169:33)
    at async bootstrap (.../dist/main.js:15:5) {
  [cause]: NatsError: TIMEOUT
      at NatsError.errorForCode (.../node_modules/nats/lib/nats-base-client/core.js:140:16)
      at timeout (.../node_modules/nats/lib/nats-base-client/util.js:57:48)
      at new RequestOne (.../node_modules/nats/lib/nats-base-client/request.js:103:41)
      at NatsConnectionImpl.request (.../node_modules/nats/lib/nats-base-client/nats.js:349:23)
      at JetStreamManagerImpl.<anonymous> (.../node_modules/nats/lib/jetstream/jsbaseclient_api.js:73:37)
      at Generator.next (<anonymous>)
      at .../node_modules/nats/lib/jetstream/jsbaseclient_api.js:22:71
      at new Promise (<anonymous>)
      at __awaiter (.../node_modules/nats/lib/jetstream/jsbaseclient_api.js:18:12)
      at JetStreamManagerImpl._request (.../node_modules/nats/lib/jetstream/jsbaseclient_api.js:66:16) {
    code: 'TIMEOUT',
    chainedError: undefined
  }
}

The webpack version that is used by nest cli is 5.90.1.

@alexander-akait
Copy link
Member

Feel free to send a PR

@dmitryrn
Copy link

In my case it seems it's not webpack, my error is logged somewhere else in Nest.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Priority - Medium
Development

No branches or pull requests

4 participants