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

Unhandled Rejection in @babel/template #10310

Open
aadityataparia opened this issue Aug 8, 2019 · 5 comments

Comments

@aadityataparia
Copy link

commented Aug 8, 2019

Bug Report

Current Behavior
@babel/template is randomly throwing error sometimes. When I listen for unhandledRejection I get:

Unhandled Rejection: [object Promise]
 reason: [extendedTrace (/Users/aadityataparia/Personal/sifrr/node_modules/@babel/template/lib/builder.js:71:31),Function.Object.assign.args [as statement] (/Users/aadityataparia/Personal/sifrr/node_modules/@babel/template/lib/builder.js:36:14),buildESModuleHeader (/Users/aadityataparia/Personal/sifrr/node_modules/@babel/plugin-transform-modules-commonjs/node_modules/@babel/helper-module-transforms/lib/index.js:234:40),rewriteModuleStatementsAndPrepareHeader (/Users/aadityataparia/Personal/sifrr/node_modules/@babel/plugin-transform-modules-commonjs/node_modules/@babel/helper-module-transforms/lib/index.js:127:18),PluginPass.exit (/Users/aadityataparia/Personal/sifrr/node_modules/@babel/plugin-transform-modules-commonjs/lib/index.js:155:85),newFn (/Users/aadityataparia/Personal/sifrr/node_modules/@babel/traverse/lib/visitors.js:193:21),NodePath._call (/Users/aadityataparia/Personal/sifrr/node_modules/@babel/traverse/lib/path/context.js:53:20),NodePath.call (/Users/aadityataparia/Personal/sifrr/node_modules/@babel/traverse/lib/path/context.js:40:17),NodePath.visit (/Users/aadityataparia/Personal/sifrr/node_modules/@babel/traverse/lib/path/context.js:97:8),TraversalContext.visitQueue (/Users/aadityataparia/Personal/sifrr/node_modules/@babel/traverse/lib/context.js:118:16)]

Babel Configuration (.babelrc, package.json, cli command)

{
	presets: [
        [
          '@babel/preset-env',
          {
            targets: {
              node: 'current'
            }
          }
        ]
      ],
      plugins: [
        [
              'istanbul',
              {
                include: ['**/src/**'],
                exclude: ['**/test/**']
              }
            ]
          ,
        ['@babel/plugin-proposal-class-properties', { loose: true }]
      ],
      ignore: [/node_modules/]
    }
}

Environment

  • Babel version(s): 7.4.0
  • Node/npm version: 10.16.0
  • OS: OSX 10.14.6
  • Monorepo: yes
  • How you are using Babel: register
@babel-bot

This comment has been minimized.

Copy link
Collaborator

commented Aug 8, 2019

Hey @aadityataparia! We really appreciate you taking the time to report an issue. The collaborators on this project attempt to help as many people as possible, but we're a limited number of volunteers, so it's possible this won't be addressed swiftly.

If you need any help, or just have general Babel or JavaScript questions, we have a vibrant Slack community that typically always has someone willing to help. You can sign-up here for an invite.

@JLHwung

This comment has been minimized.

Copy link
Contributor

commented Aug 11, 2019

Could you check in your codebase whether the builtin Error object has been overwritten?
i.e. the following snippet could generate similar error stack trace to yours.

global.Error = class extends Error {
  get stack() {
    return Promise.reject("Stack is secret");
  }
}
@aadityataparia

This comment has been minimized.

Copy link
Author

commented Aug 12, 2019

Not in my codebase, might be in some package I am using. Coundn't find in any package either. Can it be because of instrumentation by istanbul?

@JLHwung

This comment has been minimized.

Copy link
Contributor

commented Aug 12, 2019

You may check if the global Error is overwritten by

Error.prototype.constructor.toString() === "function Error() { [native code] }"

If it is not you can grep the code base from the result of Error.prototype.constructor.toString().

Can it be because of instrumentation by istanbul?

You can definitely give it a try.

@aadityataparia

This comment has been minimized.

Copy link
Author

commented Aug 13, 2019

global.Error = function Error() { [native code] }

Unhandled Rejection: [object Promise]
 reason: [extendedTrace (/Users/aadityataparia/Personal/sifrr/node_modules/@babel/template/lib/builder.js:71:31),Function.Object.assign.args [as statement] (/Users/aadityataparia/Personal/sifrr/node_modules/@babel/template/lib/builder.js:36:14),buildESModuleHeader (/Users/aadityataparia/Personal/sifrr/node_modules/@babel/plugin-transform-modules-commonjs/node_modules/@babel/helper-module-transforms/lib/index.js:234:40),rewriteModuleStatementsAndPrepareHeader (/Users/aadityataparia/Personal/sifrr/node_modules/@babel/plugin-transform-modules-commonjs/node_modules/@babel/helper-module-transforms/lib/index.js:127:18),PluginPass.exit (/Users/aadityataparia/Personal/sifrr/node_modules/@babel/plugin-transform-modules-commonjs/lib/index.js:155:85),newFn (/Users/aadityataparia/Personal/sifrr-dev/node_modules/@babel/traverse/lib/visitors.js:193:21),NodePath._call (/Users/aadityataparia/Personal/sifrr-dev/node_modules/@babel/traverse/lib/path/context.js:53:20),NodePath.call (/Users/aadityataparia/Personal/sifrr-dev/node_modules/@babel/traverse/lib/path/context.js:40:17),NodePath.visit (/Users/aadityataparia/Personal/sifrr-dev/node_modules/@babel/traverse/lib/path/context.js:97:8),TraversalContext.visitQueue (/Users/aadityataparia/Personal/sifrr-dev/node_modules/@babel/traverse/lib/context.js:118:16)]

It looks like, Error is not modified.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.