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

fix: propagate async context #2298

Merged
merged 1 commit into from
Apr 4, 2018
Merged

Conversation

ofrobots
Copy link
Contributor

@ofrobots ofrobots commented Mar 19, 2018

EDIT: This is an improvement on some of the fixes in #2295.

Starting with Nan 2.9.0, we have the ability to propagate async context
across async hops. Certain variants of Nan::Callback::Call are now
deprecated to encourage use of the context presevering alternatives.
Certain variants of Node's MakeCallback that were used internally are
going to be deprecated in Node 10.

Summary is that one should use Nan::Call for sync calls, and
Nan::Callback::Call for async. The latter expects an async resource
corresponding to the async operation to be provided at the call time.

This patch fixes things up so that 1) node-sass isn't using any
deprecated APIs, and 2) properly propagates async context for async
callbacks by creating async resources in the appropriate places.

Related: nodejs/nan#755
/cc @xzyfer

@ofrobots
Copy link
Contributor Author

I just noticed #2295. Seems like @kkoopa beat me to it.

@ofrobots
Copy link
Contributor Author

Upon deeper inspection, I think this PR should still be preferred, as it avoids creating async resources and using MakeCallback (with its tick affecting behaviour) for synchronous calls. I can rebase if folks agree.

@kkoopa
Copy link
Contributor

kkoopa commented Mar 19, 2018

Looks good as far as I can see.

This is an alternative to some of the fixes in [1].

Starting with Nan 2.9.0, we have the ability to propagate async context
across async hops. Certain variants of Nan::Callback::Call are now
deprecated to encourage use of the context presevering alternatives.
Certain variants of Node's MakeCallback that were used internally are
going to be deprecated in Node 10.

Summary is that one should use Nan::Call for sync calls, and
Nan::Callback::Call for async. The latter expects an async resource
corresponding to the async operation to be provided at the call time.

This patch fixes things up so that 1) node-sass isn't using any
deprecated APIs, and 2) properly propagates async context for async
callbacks by creating async resources in the appropriate places.

[1]: sass#2295
@ofrobots
Copy link
Contributor Author

Rebased.

@xzyfer
Copy link
Contributor

xzyfer commented Apr 4, 2018

Thanks for this @ofrobots. Looks the CI failure was transient.

@xzyfer xzyfer merged commit 1676810 into sass:master Apr 4, 2018
@ofrobots ofrobots deleted the propagate-context branch May 3, 2018 01:17
jiongle1 pushed a commit to scantist-ossops-m2/node-sass that referenced this pull request Apr 7, 2024
This change breaks browser compat for IE < 10 so it is scheduled
for 3.6. It will not be back ported to the 3.5 line.

See sass/sass#1782
Fixes sass#2298
Spec sass/sass-spec#1242
jiongle1 pushed a commit to scantist-ossops-m2/node-sass that referenced this pull request Apr 7, 2024
This change breaks browser compat for IE < 10 so it is scheduled
for 3.6. It will not be back ported to the 3.5 line.

See sass/sass#1782
Fixes sass#2298
Spec sass/sass-spec#1242
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.

None yet

3 participants