question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

The dreaded "throwing after await"

See original GitHub issue

This might be completely expected, I’m not completely up-to-date on the state of node.js, but:

Repro steps

git clone https://github.com/fasterthanlime/async-test && cd async-test
npm i
npm start

Versions

$ node --version
v8.0.0

$ npm list
async-test@1.0.0 C:\msys64\home\amwenger\Dev\async-test
`-- trace@3.0.0
  `-- stack-chain@1.3.7

Output

=================================
 Throwing first thing
=================================
Full stack trace:
Error: throwing first thing
    at cherrypie (C:\msys64\home\amwenger\Dev\async-test\index.js:12:13)
    at binomial (C:\msys64\home\amwenger\Dev\async-test\index.js:14:40)
    at abacus (C:\msys64\home\amwenger\Dev\async-test\index.js:15:38)
    at main (C:\msys64\home\amwenger\Dev\async-test\index.js:16:22)
    at Object.<anonymous> (C:\msys64\home\amwenger\Dev\async-test\index.js:34:1)
    at Module._compile (module.js:569:30)
    at Object.Module._extensions..js (module.js:580:10)
    at Module.load (module.js:503:32)
    at tryModuleLoad (module.js:466:12)
    at Function.Module._load (module.js:458:3)
    at Function.Module.runMain (module.js:605:10)
    at startup (bootstrap_node.js:158:16)
    at bootstrap_node.js:575:3
    at <anonymous>
    at checkStack (C:\msys64\home\amwenger\Dev\async-test\index.js:38:5)
    at main (C:\msys64\home\amwenger\Dev\async-test\index.js:16:11)
    at Object.<anonymous> (C:\msys64\home\amwenger\Dev\async-test\index.js:34:1)
    at Module._compile (module.js:569:30)
    at Object.Module._extensions..js (module.js:580:10)
    at Module.load (module.js:503:32)
    at tryModuleLoad (module.js:466:12)
    at Function.Module._load (module.js:458:3)
    at Function.Module.runMain (module.js:605:10)
    at startup (bootstrap_node.js:158:16)
    at bootstrap_node.js:575:3


=================================
 Throwing after await
=================================
Full stack trace:
Error: after timeout
    at cherrypie (C:\msys64\home\amwenger\Dev\async-test\index.js:26:13)
    at <anonymous>
    at <anonymous>
    at checkStack (C:\msys64\home\amwenger\Dev\async-test\index.js:38:5)
    at main (C:\msys64\home\amwenger\Dev\async-test\index.js:30:11)
    at <anonymous>
    at runMicrotasksCallback (internal/process/next_tick.js:86:5)
    at _combinedTickCallback (internal/process/next_tick.js:95:7)
    at process._tickCallback (internal/process/next_tick.js:161:9)
    at Function.Module.runMain (module.js:607:11)
    at startup (bootstrap_node.js:158:16)
    at bootstrap_node.js:575:3


didn't see abacus, bailing

Expected output

In the second trace, something like:

<snip>
Error: after timeout
    at cherrypie (C:\msys64\home\amwenger\Dev\async-test\index.js:26:13)
    at binomial (path:line)
    at abacus (path:line)
<snip>

Issue Analytics

  • State:open
  • Created 6 years ago
  • Reactions:2
  • Comments:19 (10 by maintainers)

github_iconTop GitHub Comments

1reaction
AndreasMadsencommented, Jun 26, 2017

I have no doubt that they all have subtle implementation differences though.

They have subtle differences in the standard too. It is about how many rounds the microtask queue take. Promise.resolve(1).then((val) => Promise.resolve(val)).then(...) results in the same as Promise.resolve(1).then(...) but they behave slightly differently.

The noise bothers me a lot less than missing frames 😃

I know, but that was an issue I understood 😃

0reactions
jbunton-atlassiancommented, Feb 23, 2018

Hi there. I think I’ve solved this in #40. I’d love any feedback or testing anybody could give this code 😃

You can try it out by installing it from my repo:

npm install 'git://github.com/jbunton-atlassian/trace#a4e78d89e09ab4830f302bf85a30a528a5746e0b'
Read more comments on GitHub >

github_iconTop Results From Across the Web

5 Tips and Thoughts on Async / Await Functions
Simply put, you're throwing an error if it happens, but you're not 'catching' and responding to it. The solution? Treat the call to...
Read more >
Why does exception still get thrown after catch in async ...
Because you're converting rejection to fulfillment with your catch handler. The await will await the promise returned by catch , which never ...
Read more >
How to Throw Errors From Async Functions in JavaScript?
In the following post you'll learn: how to throw errors from async functions in JavaScript; how to test exception from async functions with ......
Read more >
Practical Async/Await - Maxim Orlov
You're calling an asynchronous function and log the result: Calling an asynchronous getUser function and assigning the result to a user variable. Console ......
Read more >
Error handling with Async/Await in JS | by Ian Segers | ITNEXT
This works as expected, we call the function thisThrows() which throws a regular error, we catch it, log the error and optionally we...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found