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

stacktraces from async functions break error reporting #24863

Closed
mathewTH opened this issue Jun 8, 2020 · 11 comments · Fixed by #33712
Closed

stacktraces from async functions break error reporting #24863

mathewTH opened this issue Jun 8, 2020 · 11 comments · Fixed by #33712
Labels
good first issue Issue that doesn't require previous experience with Gatsby help wanted Issue with a clear description that the community can help with. not stale topic: cli Related to the Gatsby CLI type: bug An issue or pull request relating to a bug in Gatsby

Comments

@mathewTH
Copy link

mathewTH commented Jun 8, 2020

Description

Error while processing an error generated by a source plugin.
Gatsby tries to open an invalid filename from the stack trace. This causes a new error that hides the original plugin error.

Steps to reproduce

I'm unsure of exact steps, although if necessary I might be able to create some. But from what I have seen, I believe it could be triggered when a plugin throws an exception with a stack trace entry which contains gatsby-node but is not a valid filename. In my case the invalid filename is async C:\Users\Mathew\Development\dive-club-gatsby\node_modules\gatsby-source-google-spreadsheet\gatsby-node.js.

Expected result

Something like the following:

success Downloading remote files - 1.524s - 2/2 1.31/s

 ERROR #11321  PLUGIN


"gatsby-source-google-spreadsheet" threw an error while running the sourceNodes lifecycle:

Cannot read property 'map' of undefined



  TypeError: Cannot read property 'map' of undefined

  - sheets.js:216 sheetToTable
    [dive-club-gatsby]/[node-sheets]/lib/sheets.js:216:4

  - Array.map

  - sheets.js:191 Sheets.tables
    [dive-club-gatsby]/[node-sheets]/lib/sheets.js:191:37

  - task_queues.js:97 processTicksAndRejections
    internal/process/task_queues.js:97:5

  - gatsby-node.js:27
    [dive-club-gatsby]/[gatsby-source-google-spreadsheet]/gatsby-node.js:27:20

  - async Promise.all


success source and transform nodes - 12.578s

I produced that output by modifying api-runner-node.js, adding

if(/google-spreadsheet\\gatsby-node/.test(file.fileName)){
    file = null;
}

after line 383 const file = stackTrace.parse(err).find(file => /gatsby-node/.test(file.fileName)); (changing const to let too) and before if (file) {.

Actual result

UNHANDLED REJECTION ENOENT: no such file or directory, open 'async C:\Users\Mathew\Development\dive-club-gatsby\node_modules\gatsby-source-google-spreadsheet\gatsby-node.js'



  Error: ENOENT: no such file or directory, open 'async C:\Users\Mathew\Development\dive-club-gatsby\node_modules\gatsby-source-google-spreadsheet\gatsby-node.js'

  - api-runner-node.js:395
    [dive-club-gatsby]/[gatsby]/dist/utils/api-runner-node.js:395:25

  - util.js:16 tryCatcher
    [dive-club-gatsby]/[bluebird]/js/release/util.js:16:23

  - promise.js:547 Promise._settlePromiseFromHandler
    [dive-club-gatsby]/[bluebird]/js/release/promise.js:547:31


  - promise.js:604 Promise._settlePromise
    [dive-club-gatsby]/[bluebird]/js/release/promise.js:604:18

  - promise.js:649 Promise._settlePromise0
    [dive-club-gatsby]/[bluebird]/js/release/promise.js:649:10

  - promise.js:725 Promise._settlePromises
    [dive-club-gatsby]/[bluebird]/js/release/promise.js:725:18

  - async.js:93 _drainQueueStep
    [dive-club-gatsby]/[bluebird]/js/release/async.js:93:12

  - async.js:86 _drainQueue
    [dive-club-gatsby]/[bluebird]/js/release/async.js:86:9

  - async.js:102 Async._drainQueues
    [dive-club-gatsby]/[bluebird]/js/release/async.js:102:5

  - async.js:15 Immediate.Async.drainQueues [as _onImmediate]
    [dive-club-gatsby]/[bluebird]/js/release/async.js:15:14

  - timers.js:456 processImmediate
    internal/timers.js:456:21

not finished source and transform nodes - 11.189s

Environment

  System:
    OS: Windows 10 10.0.18362
    CPU: (4) x64 Intel(R) Core(TM) i5-2450M CPU @ 2.50GHz
  Binaries:
    Node: 12.16.1 - C:\Program Files\nodejs\node.EXE
    npm: 6.13.4 - C:\Program Files\nodejs\npm.CMD
  Languages:
    Python: 3.7.3 - /c/Program Files/Python37/python
  Browsers:
    Edge: 44.18362.449.0
  npmPackages:
    gatsby: ^2.21.22 => 2.21.22
    gatsby-image: ^2.4.3 => 2.4.3
    gatsby-plugin-manifest: ^2.4.2 => 2.4.2
    gatsby-plugin-offline: ^3.2.1 => 3.2.1
    gatsby-plugin-purgecss: ^5.0.0 => 5.0.0
    gatsby-plugin-react-helmet: ^3.3.1 => 3.3.1
    gatsby-plugin-sass: ^2.3.1 => 2.3.1
    gatsby-plugin-sharp: ^2.6.2 => 2.6.2
    gatsby-remark-images: ^3.3.8 => 3.3.8
    gatsby-source-filesystem: ^2.3.1 => 2.3.1
    gatsby-source-google-docs: ^2.0.0-beta.9 => 2.0.0-beta.9
    gatsby-source-google-spreadsheet: ^2.0.0 => 2.0.0
    gatsby-transformer-remark: ^2.8.13 => 2.8.13
    gatsby-transformer-sharp: ^2.5.2 => 2.5.2
  npmGlobalPackages:
    gatsby-cli: 2.12.44
@mathewTH mathewTH added the type: bug An issue or pull request relating to a bug in Gatsby label Jun 8, 2020
@gatsbot gatsbot bot added the status: triage needed Issue or pull request that need to be triaged and assigned to a reviewer label Jun 8, 2020
@danabrit
Copy link
Contributor

danabrit commented Jun 9, 2020

Hi @mathewTH !

Sorry to hear you're running into an issue. To help us best begin debugging the underlying cause, it is incredibly helpful if you're able to create a minimal reproduction. This is a simplified example of the issue that makes it clear and obvious what the issue is and how we can begin to debug it.

If you're up for it, we'd very much appreciate if you could provide a minimal reproduction and we'll be able to take another look.

Thanks for using Gatsby! 💜

@danabrit danabrit added status: needs reproduction This issue needs a simplified reproduction of the bug for further troubleshooting. and removed status: triage needed Issue or pull request that need to be triaged and assigned to a reviewer labels Jun 9, 2020
@mathewTH
Copy link
Author

mathewTH commented Jun 10, 2020

I have reproduced the bug using https://github.com/mathewTH/gatsby-bug-24863-repro
However, since the plugin that exposed the gatsby bug for me is using google sheets api, a service account is needed (unless I've missed another way for a google api key to be attached to the request). The sheet I'm using for repro is public, so any service account with sheets api turned on will work. I could supply a working .env file for testing, if necessary.

@ascorbic
Copy link
Contributor

Hi @mathewTH . I'm a bit confused here, because it seems to be doing what it's supposed to be doing. Does the file C:\Users\Mathew\Development\dive-club-gatsby\node_modules\gatsby-source-google-spreadsheet\gatsby-node.js actually exist? The code there is trying to load that file so that it can highlight the context of the error. I'm confused as to why the stack frame has that filename, but the file doesn't exist.

@ascorbic ascorbic added status: awaiting author response Additional information has been requested from the author and removed status: needs reproduction This issue needs a simplified reproduction of the bug for further troubleshooting. labels Jun 18, 2020
@mathewTH
Copy link
Author

mathewTH commented Jun 23, 2020 via email

@github-actions
Copy link

Hiya!

This issue has gone quiet. Spooky quiet. 👻

We get a lot of issues, so we currently close issues after 30 days of inactivity. It’s been at least 20 days since the last update here.
If we missed this issue or if you want to keep it open, please reply here. You can also add the label "not stale" to keep this issue open!
As a friendly reminder: the best way to see this issue, or any other, fixed is to open a Pull Request. Check out gatsby.dev/contribute for more information about opening PRs, triaging issues, and contributing!

Thanks for being a part of the Gatsby community! 💪💜

@github-actions github-actions bot added the stale? Issue that may be closed soon due to the original author not responding any more. label Jul 14, 2020
@freiksenet
Copy link
Contributor

freiksenet commented Jul 15, 2020

@mathewTH Thank you for a great reproduction! I've confirmed this bug on the latest gatsby. This seems to be a problem with stacktrace library that we are using. I'll debug/fix it later if I have time.

To fix this problem one would replace stacktrace library with a inlined version that works for async functions. In addition, adding a test to error reporting would be useful.

@freiksenet freiksenet added not stale and removed stale? Issue that may be closed soon due to the original author not responding any more. status: awaiting author response Additional information has been requested from the author labels Jul 15, 2020
@freiksenet freiksenet changed the title 'ENOENT: no such file or directory, open' while processing source plugin error, hides original error stacktraces from async functions break error reporting Jul 15, 2020
@freiksenet freiksenet added topic: cli Related to the Gatsby CLI good first issue Issue that doesn't require previous experience with Gatsby help wanted Issue with a clear description that the community can help with. labels Jul 15, 2020
@fakeharahman
Copy link

Hi, I'm new to open source, can I try to solve this issue?

@CIPHERTron
Copy link

Is this issue still up for grab?

@Arkadipta-Chatterjee
Copy link

Can i work on this issue?

@shikhar13012001
Copy link

Hi I am new to Open Source , can I work on this issue?

@KyleAMathews
Copy link
Contributor

All open issues are open for working on unless someone has explicitly started working on it e.g. there's an open PR.

So jump in!

@tysg's PR might be the right approach still — #27262

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Issue that doesn't require previous experience with Gatsby help wanted Issue with a clear description that the community can help with. not stale topic: cli Related to the Gatsby CLI type: bug An issue or pull request relating to a bug in Gatsby
Projects
None yet
9 participants