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

asyncjs: add then, catch for promise pipelining #16871

Merged
merged 8 commits into from
Feb 24, 2021

Conversation

timotheecour
Copy link
Member

@timotheecour timotheecour commented Jan 30, 2021

prerequisite for things like jsfetch #12531

note

  • --unhandled-rejections=strict node flag is now passed in testament for nodejs tests, so that tests/js/tasyncjs_fail.nim returns exit code != 0 (and so that this test succeeds). This flag is explained in https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode and is the default starting with node >= 15.0.0

with this flag, for nodejs < 15.0.0 (all except freebsd CI), you'd get exit code 0 and this message:

(Use node --trace-warnings ... to show where the warning was created)
(node:72796) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag --unhandled-rejections=strict (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 3)
(node:72796) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

links

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/catch etc

future work

nim r -b:js --lib:lib -d:nodejs --passnode:--unhandled-rejections=strict tests/js/tasyncjs_fail.nim

after which i can mark expected exitcode as != 0 for tests/js/tasyncjs_fail.nim

it'd be handled here: in compiler/nim.nim near execExternalProgram(conf, cmdPrefix & output.quoteShell & ' ' & conf.arguments)

@timotheecour timotheecour marked this pull request as draft January 30, 2021 05:00
lib/js/asyncjs.nim Outdated Show resolved Hide resolved
tests/js/tasync.nim Outdated Show resolved Hide resolved
@juancarlospaco
Copy link
Collaborator

Changelog.

@juancarlospaco
Copy link
Collaborator

juancarlospaco commented Feb 16, 2021

@timotheecour Approx ETA ?, is doable?, is needed for #12531 🙂

@timotheecour
Copy link
Member Author

@juancarlospaco ok, getting back to this, thanks for the ping...

@juancarlospaco
Copy link
Collaborator

...was just asking, but Ok 🙂

@timotheecour
Copy link
Member Author

@juancarlospaco PTAL

Changelog.

also, IMO it's better usually to add review comments in the file view instead of the main PR thread so they remain threaded and so I can mark each of them as individually resolved; maybe except for important comments that should garner more attention from other reviewers

@timotheecour timotheecour marked this pull request as ready for review February 18, 2021 04:32
@timotheecour
Copy link
Member Author

timotheecour commented Feb 18, 2021

how come CI didn't run in azure?
EDIT: i restarted CI

@timotheecour timotheecour reopened this Feb 18, 2021
@timotheecour timotheecour changed the title asyncjs: add then, catch asyncjs: add then, catch for promise pipelining Feb 18, 2021
lib/js/asyncjs.nim Outdated Show resolved Hide resolved
changelog.md Outdated Show resolved Hide resolved
@timotheecour
Copy link
Member Author

ping @xflywind to unblock jsfetch #12531

compiler/nim.nim Show resolved Hide resolved
@timotheecour timotheecour added the TODO: followup needed remove tag once fixed or tracked elsewhere label Feb 24, 2021
@Araq Araq merged commit a4e6b24 into nim-lang:devel Feb 24, 2021
@timotheecour timotheecour deleted the pr_asyncjs_then_catch branch February 24, 2021 20:31
timotheecour added a commit to timotheecour/Nim that referenced this pull request Feb 25, 2021
timotheecour added a commit to timotheecour/Nim that referenced this pull request Feb 26, 2021
timotheecour added a commit to timotheecour/Nim that referenced this pull request Mar 4, 2021
Araq pushed a commit that referenced this pull request Mar 4, 2021
#17189)

* followup #16871 asyncjs.then: allow pipelining procs returning futures
* rename test files where they belong
* fix tests
* tests for then with `onReject` callback
* rename test file containing fail to avoid messing with grep
* address comments
* cleanup
* un-disable 1 test
ringabout pushed a commit to ringabout/Nim that referenced this pull request Mar 22, 2021
* asyncjs: add then
* improve tests, changelog, API
* fix cryptic windows error: The parameter is incorrect
* address comments
ringabout pushed a commit to ringabout/Nim that referenced this pull request Mar 22, 2021
…g futures (nim-lang#17189)

* followup nim-lang#16871 asyncjs.then: allow pipelining procs returning futures
* rename test files where they belong
* fix tests
* tests for then with `onReject` callback
* rename test file containing fail to avoid messing with grep
* address comments
* cleanup
* un-disable 1 test
ardek66 pushed a commit to ardek66/Nim that referenced this pull request Mar 26, 2021
* asyncjs: add then
* improve tests, changelog, API
* fix cryptic windows error: The parameter is incorrect
* address comments
ardek66 pushed a commit to ardek66/Nim that referenced this pull request Mar 26, 2021
…g futures (nim-lang#17189)

* followup nim-lang#16871 asyncjs.then: allow pipelining procs returning futures
* rename test files where they belong
* fix tests
* tests for then with `onReject` callback
* rename test file containing fail to avoid messing with grep
* address comments
* cleanup
* un-disable 1 test
@metagn metagn removed the TODO: followup needed remove tag once fixed or tracked elsewhere label Jan 4, 2024
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

Successfully merging this pull request may close these issues.

5 participants