Repository navigation
Conversation
mmomtchev
left a comment
There was a problem hiding this comment.
Returning a non-copyable object from a factory using an initializer-list is C++11.
| inline node::CallbackScope makeCallbackScope(v8::Local<v8::Object> target) { | ||
| return {v8::Isolate::GetCurrent(), target, context}; | ||
| } | ||
| #endif |
There was a problem hiding this comment.
doesn't this require an ifdef for all users supporting ancient node.js versions if there is no dummy implementation for these older node.js versions?
There was a problem hiding this comment.
There is an #ifdef.
There was a problem hiding this comment.
When it comes to the users, the users do not have any choice as this does not work the same way before Node.js 9.0.0. There are no AsyncResources at all.
There was a problem hiding this comment.
But here AsyncResource does exist for all versions of Node, it just does not perform the non-applicable operations on old versions, leading to the same observable end result.
There was a problem hiding this comment.
Also, why is the typecast needed now? ::context is a node::async_context.
There was a problem hiding this comment.
The problem is that node::CallbackScope does not exist, so the user will have to use an ifdef.
The only way that I see around this is to wrap the whole construction and add a Nan::CallbackScope that is an empty object on Node <9.0.0.
There was a problem hiding this comment.
Okay, I think I understand. Introducing a dummy Nan::CallbackScope is fine, but would it not make sense to have it just do a Nan::MakeCallback for old versions, so the function at least gets called. Am I right in thinking that on versions of Node before 9.0, the closest match would be to just run the callback and call it a day?
There was a problem hiding this comment.
Nan::CallbackScope is just a RIAA guard that means to run the micro tasks when the scope is exited. I wonder how did this work before Node 9.0.0 which introduced the async contexts, 'CallbackScopeandMakeCallback`.
I am not very sure if before Node 9, binary modules had to run themselves the micro tasks or not.
There was a problem hiding this comment.
So the proposal is to add an #error in this case.
The rationale is that this is something modules will have to add now in order to work correctly on Node 26+, while dropping support for Node 8 and earlier.
Anyway, I am afraid that there is no way to safely implement this on Node 8 - this was before Promise was common and all C++ modules used callbacks which do not have this problem.
|
You are right, there should be noop implementations for the ancient
versions.
…On Fri, Sep 25, 2026, 21:51 Gerhard Stöbich ***@***.***> wrote:
***@***.**** commented on this pull request.
------------------------------
In nan.h <#1026 (comment)>:
> @@ -660,6 +660,12 @@ class AsyncResource {
#endif
}
+#if NODE_MODULE_VERSION >= NODE_9_0_MODULE_VERSION
+ inline node::CallbackScope makeCallbackScope(v8::Local<v8::Object> target) {
+ return {v8::Isolate::GetCurrent(), target, context};
+ }
+#endif
doesn't this require an ifdef for all consumer supporting ancient node.js
versions if there is no dummy implementation for these older node.js
versions?
—
Reply to this email directly, view it on GitHub
<#1026?email_source=notifications&email_token=AA7JXKOESZXZBKH6S3RD7R35Q25BVA5CNFSNUABKM5UWIORPF5TWS5BNNB2WEL2QOVWGYUTFOF2WK43UKJSXM2LFO4XTKMZSGE2TAOJTHE42M4TFMFZW63VKON2WE43DOJUWEZLEUVSXMZLOOSWGM33PORSXEX3DNRUWG2Y#pullrequestreview-5321509399>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AA7JXKOOLXTRTD2I5HHJQRL5Q25BVAVCNFSNUABEKJSXA33TNF2G64TZHMYTCNJUGU4TEOB3JFZXG5LFHM2TKNJTGU3TIOJZGCQXMAQ>
.
Triage notifications, keep track of coding agent tasks and review pull
requests on the go with GitHub Mobile for iOS
<https://github.com/notifications/mobile/ios/AA7JXKJWICMHP2BFZYKSST35Q25BVA5CNFSNUABKM5UWIORPF5TWS5BNNB2WEL2QOVWGYUTFOF2WK43UKJSXM2LFO4XTKMZSGE2TAOJTHE42M4TFMFZW63VKON2WE43DOJUWEZLEUVSXMZLOOSVGM33PORSXEX3JN5ZQ>
and Android
<https://github.com/notifications/mobile/android/AA7JXKPFBHQI667LXA3IC4T5Q25BVA5CNFSNUABKM5UWIORPF5TWS5BNNB2WEL2QOVWGYUTFOF2WK43UKJSXM2LFO4XTKMZSGE2TAOJTHE42M4TFMFZW63VKON2WE43DOJUWEZLEUVSXMZLOOSXGM33PORSXEX3BNZSHE33JMQ>.
Download it today!
You are receiving this because you are subscribed to this thread.Message
ID: ***@***.***>
|
|
Alright, I got back to this now. I like what I see. Based on what I could see from the discussions over in nodejs/node, it seems like doing this is the way forward. Using the C++11 feature for |
I might lack a bit of context here, but could this not be resolved with a friend function? |
No, the user class needs it. |
|
Alright, then I am fully aboard.
…On Wed, Oct 14, 2026, 23:09 Momtchil Momtchev ***@***.***> wrote:
*mmomtchev* left a comment (nodejs/nan#1026)
<#1026 (comment)>
The problem with calling node::CallbackScope directly is that the
node::async_context is a private member of nan::AsyncResource.
I might lack a bit of context here, but could this not be resolved with a
friend function?
No, the user class needs it.
—
Reply to this email directly, view it on GitHub
<#1026?email_source=notifications&email_token=AA7JXKNQ54UNN3FHW5GQXRL5T7MRBA5CNFSNUABFM5UWIORPF5TWS5BNNB2WEL2JONZXKZKDN5WW2ZLOOQXTMMJXG4ZTIMBSGAZ2M4TFMFZW63VHMNXW23LFNZ2KKZLWMVXHJLDGN5XXIZLSL5RWY2LDNM#issuecomment-6177340203>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AA7JXKLMXDJ2TIL3C5EXKK35T7MRBAVCNFSNUABEKJSXA33TNF2G64TZHMYTCNJUGU4TEOB3JFZXG5LFHM2TKNJTGU3TIOJZGCQXMAQ>
.
Triage notifications, keep track of coding agent tasks and review pull
requests on the go with GitHub Mobile for iOS
<https://github.com/notifications/mobile/ios/AA7JXKLJEQ4XVDZQ4FLCJ2D5T7MRBA5CNFSNUABFM5UWIORPF5TWS5BNNB2WEL2JONZXKZKDN5WW2ZLOOQXTMMJXG4ZTIMBSGAZ2M4TFMFZW63VHMNXW23LFNZ2KKZLWMVXHJKTGN5XXIZLSL5UW64Y>
and Android
<https://github.com/notifications/mobile/android/AA7JXKJ2WTPWDTXKZTRWUTL5T7MRBA5CNFSNUABFM5UWIORPF5TWS5BNNB2WEL2JONZXKZKDN5WW2ZLOOQXTMMJXG4ZTIMBSGAZ2M4TFMFZW63VHMNXW23LFNZ2KKZLWMVXHJLTGN5XXIZLSL5QW4ZDSN5UWI>.
Download it today!
You are receiving this because you commented.Message ID:
***@***.***>
|
|
In fact, when looking at |
|
Yeah, this change in behavior is going to cause a lot of issues, but it is
more correct. The best we can do on the NAN side is raise awareness and
minimize the disruptions. Your documentation here was very good.
Would it make sense to update the other relevant Nan tests/examples with
this change as well, since it should not do any harm while dispatching to
js?
…On Thu, Oct 15, 2026, 14:33 Momtchil Momtchev ***@***.***> wrote:
*mmomtchev* left a comment (nodejs/nan#1026)
<#1026 (comment)>
In fact, when looking at node-addon-api where the situation is similar,
they went the other way around, with an operator node::async_context
instead of a factory and I think that this is indeed less awkward for the
user. I will change it, but I am just waiting to see where this is going
because there will be an outcry from async module authors when people start
switching to Node 26. Most people still do not realise the implications. I
think there should be at least a "heads up" from Node.
—
Reply to this email directly, view it on GitHub
<#1026?email_source=notifications&email_token=AA7JXKJD2EXMOIJ32P53EMT5UCYYXA5CNFSNUABFM5UWIORPF5TWS5BNNB2WEL2JONZXKZKDN5WW2ZLOOQXTMMJZGEYDMNJUGUZ2M4TFMFZW63VHMNXW23LFNZ2KKZLWMVXHJLDGN5XXIZLSL5RWY2LDNM#issuecomment-6191065453>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AA7JXKLWSG6S42SAYBKIPND5UCYYXAVCNFSNUABEKJSXA33TNF2G64TZHMYTCNJUGU4TEOB3JFZXG5LFHM2TKNJTGU3TIOJZGCQXMAQ>
.
Triage notifications, keep track of coding agent tasks and review pull
requests on the go with GitHub Mobile for iOS
<https://github.com/notifications/mobile/ios/AA7JXKL63SENW2KUOT5BEKL5UCYYXA5CNFSNUABFM5UWIORPF5TWS5BNNB2WEL2JONZXKZKDN5WW2ZLOOQXTMMJZGEYDMNJUGUZ2M4TFMFZW63VHMNXW23LFNZ2KKZLWMVXHJKTGN5XXIZLSL5UW64Y>
and Android
<https://github.com/notifications/mobile/android/AA7JXKILO5AWUD5542MLNXD5UCYYXA5CNFSNUABFM5UWIORPF5TWS5BNNB2WEL2JONZXKZKDN5WW2ZLOOQXTMMJZGEYDMNJUGUZ2M4TFMFZW63VHMNXW23LFNZ2KKZLWMVXHJLTGN5XXIZLSL5QW4ZDSN5UWI>.
Download it today!
You are receiving this because you commented.Message ID:
***@***.***>
|
node::async_context from Nan::AsyncResource
|
There was one segfault on a different test on |
|
I did a quick search through the isssue tracker. I do not remember if there
always was a microtask queue, but this seems relevant
#284
This was the original PR for AsyncResource
#729
…On Thu, Oct 15, 2026, 19:57 Momtchil Momtchev ***@***.***> wrote:
***@***.**** commented on this pull request.
------------------------------
In nan.h <#1026 (comment)>:
> @@ -660,6 +660,12 @@ class AsyncResource {
#endif
}
+#if NODE_MODULE_VERSION >= NODE_9_0_MODULE_VERSION
+ inline node::CallbackScope makeCallbackScope(v8::Local<v8::Object> target) {
+ return {v8::Isolate::GetCurrent(), target, context};
+ }
+#endif
Nan::CallbackScope is just a RIAA guard that means to run the micro tasks
when the scope is exited. I wonder how did this work before Node 9.0.0
which introduced the async contexts, 'CallbackScopeandMakeCallback`.
I am not very sure if before Node 9, binary modules had to run themselves
the micro tasks or not.
—
Reply to this email directly, view it on GitHub
<#1026?email_source=notifications&email_token=AA7JXKMJNIUQ76FJWINSR4D5UD6YZA5CNFSNUABKM5UWIORPF5TWS5BNNB2WEL2QOVWGYUTFOF2WK43UKJSXM2LFO4XTKNJTGY4DQMRXG422M4TFMFZW63VHMNXW23LFNZ2KKZLWMVXHJLDGN5XXIZLSL5RWY2LDNM#discussion_r4285887651>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AA7JXKJCYY7HIPHJ2RGUVE35UD6YZAVCNFSNUABEKJSXA33TNF2G64TZHMYTCNJUGU4TEOB3JFZXG5LFHM2TKNJTGU3TIOJZGCQXMAQ>
.
Triage notifications, keep track of coding agent tasks and review pull
requests on the go with GitHub Mobile for iOS
<https://github.com/notifications/mobile/ios/AA7JXKJLIM7YI27FII7UOET5UD6YZA5CNFSNUABKM5UWIORPF5TWS5BNNB2WEL2QOVWGYUTFOF2WK43UKJSXM2LFO4XTKNJTGY4DQMRXG422M4TFMFZW63VHMNXW23LFNZ2KKZLWMVXHJKTGN5XXIZLSL5UW64Y>
and Android
<https://github.com/notifications/mobile/android/AA7JXKMSODUOLXQB4GWECNL5UD6YZA5CNFSNUABKM5UWIORPF5TWS5BNNB2WEL2QOVWGYUTFOF2WK43UKJSXM2LFO4XTKNJTGY4DQMRXG422M4TFMFZW63VHMNXW23LFNZ2KKZLWMVXHJLTGN5XXIZLSL5QW4ZDSN5UWI>.
Download it today!
You are receiving this because you commented.Message ID:
***@***.***>
|
|
The single entry point API for handling the micro tasks was actually introduced in Node 8: In Node 6, calling the micro tasks was implemented directly in Before this it was somewhat of a mess that was spread around, including the http module. There was a I am afraid that there is no safe way to implement this feature - running the micro tasks without JS on the stack and without calling JS - below Node 8. At the very least, it will require extensive testing with older Node versions. |
|
Thank you for the great analysis. Then it is not worth further effort.
The new test can just return a failure on versions below nine, along with a
documentation note and some preprocesssor conditionals to have a clean
compilation as long as this is not used with ancient Node will have to do.
The real-world impact of this wart ought to be insignificant and we can all
live happily ever after.
On a tangential note, I saw a c-style cast in the test itself, please
change that to a static_cast.
…On Thu, Oct 15, 2026, 20:50 Momtchil Momtchev ***@***.***> wrote:
*mmomtchev* left a comment (nodejs/nan#1026)
<#1026 (comment)>
The single entry point API for handling the micro tasks was actually
introduced in Node 8:
https://github.com/nodejs/node/pull/14697/changes
In Node 6, calling the micro tasks was implemented directly in
MakeCallback:
***@***.***
<nodejs/node@41f333e>
Before this it was somewhat of a mess that was spread around, including
the http module. There was a KickNextTick entry point.
I am afraid that there is no safe way to implement this feature - running
the micro tasks without JS on the stack and without calling JS - below Node
8. At the very least, it will require extensive testing with older Node
versions.
—
Reply to this email directly, view it on GitHub
<#1026?email_source=notifications&email_token=AA7JXKKDC3J4SXTMY7HWMIT5UEE55A5CNFSNUABFM5UWIORPF5TWS5BNNB2WEL2JONZXKZKDN5WW2ZLOOQXTMMJZHA2TSNZXGYYKM4TFMFZW63VHMNXW23LFNZ2KKZLWMVXHJLDGN5XXIZLSL5RWY2LDNM#issuecomment-6198597760>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AA7JXKLKNEFV5FFP3PFTEQT5UEE55AVCNFSNUABEKJSXA33TNF2G64TZHMYTCNJUGU4TEOB3JFZXG5LFHM2TKNJTGU3TIOJZGCQXMAQ>
.
Triage notifications, keep track of coding agent tasks and review pull
requests on the go with GitHub Mobile for iOS
<https://github.com/notifications/mobile/ios/AA7JXKNCMQQ2ID3E5TNAJXL5UEE55A5CNFSNUABFM5UWIORPF5TWS5BNNB2WEL2JONZXKZKDN5WW2ZLOOQXTMMJZHA2TSNZXGYYKM4TFMFZW63VHMNXW23LFNZ2KKZLWMVXHJKTGN5XXIZLSL5UW64Y>
and Android
<https://github.com/notifications/mobile/android/AA7JXKITF75WVPS4DW3OV2T5UEE55A5CNFSNUABFM5UWIORPF5TWS5BNNB2WEL2JONZXKZKDN5WW2ZLOOQXTMMJZHA2TSNZXGYYKM4TFMFZW63VHMNXW23LFNZ2KKZLWMVXHJLTGN5XXIZLSL5QW4ZDSN5UWI>.
Download it today!
You are receiving this because you commented.Message ID:
***@***.***>
|
|
Maybe it should fail with an |
|
I would prefer the rest of NAN to still be usable on those ancient
versions, as long as one does not try to actually use async resources.
…On Fri, Oct 16, 2026, 14:27 Momtchil Momtchev ***@***.***> wrote:
***@***.**** commented on this pull request.
------------------------------
In nan.h <#1026 (comment)>:
> @@ -660,6 +660,12 @@ class AsyncResource {
#endif
}
+#if NODE_MODULE_VERSION >= NODE_9_0_MODULE_VERSION
+ inline node::CallbackScope makeCallbackScope(v8::Local<v8::Object> target) {
+ return {v8::Isolate::GetCurrent(), target, context};
+ }
+#endif
So the proposal is to add an #error in this case.
The rationale is that this is something modules will have to add now in
order to work correctly on Node 26+, while dropping support for Node 8 and
earlier.
Anyway, I am afraid that there is no way to safely implement this on Node
8 - this was before Promise was common and all C++ modules used callbacks
which do not have this problem.
—
Reply to this email directly, view it on GitHub
<#1026?email_source=notifications&email_token=AA7JXKLND3MADKXDP6SCJBL5UIA3BA5CNFSNUABKM5UWIORPF5TWS5BNNB2WEL2QOVWGYUTFOF2WK43UKJSXM2LFO4XTKNJUG4YTINZXG422M4TFMFZW63VHMNXW23LFNZ2KKZLWMVXHJLDGN5XXIZLSL5RWY2LDNM#discussion_r4294158752>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AA7JXKMOLAUGJ22NTG4LPH35UIA3BAVCNFSNUABEKJSXA33TNF2G64TZHMYTCNJUGU4TEOB3JFZXG5LFHM2TKNJTGU3TIOJZGCQXMAQ>
.
Triage notifications, keep track of coding agent tasks and review pull
requests on the go with GitHub Mobile for iOS
<https://github.com/notifications/mobile/ios/AA7JXKOQ6QEVOH3UAOOEC5L5UIA3BA5CNFSNUABKM5UWIORPF5TWS5BNNB2WEL2QOVWGYUTFOF2WK43UKJSXM2LFO4XTKNJUG4YTINZXG422M4TFMFZW63VHMNXW23LFNZ2KKZLWMVXHJKTGN5XXIZLSL5UW64Y>
and Android
<https://github.com/notifications/mobile/android/AA7JXKM4GUYPZWUGZTLOHAD5UIA3BA5CNFSNUABKM5UWIORPF5TWS5BNNB2WEL2QOVWGYUTFOF2WK43UKJSXM2LFO4XTKNJUG4YTINZXG422M4TFMFZW63VHMNXW23LFNZ2KKZLWMVXHJLTGN5XXIZLSL5QW4ZDSN5UWI>.
Download it today!
You are receiving this because you commented.Message ID:
***@***.***>
|
|
```
template<int E>
struct Foo {
char b[2*E-1];
};
/* usage */
Foo<(int)(NODE_MOD_VER > 123)> assertion;
```
Something along those lines. I can make an actual implementation tomorrow
if that helps.
…On Fri, Oct 16, 2026, 14:38 Benjamin Byholm ***@***.***> wrote:
I would prefer the rest of NAN to still be usable on those ancient
versions, as long as one does not try to actually use async resources.
On Fri, Oct 16, 2026, 14:27 Momtchil Momtchev ***@***.***>
wrote:
> ***@***.**** commented on this pull request.
> ------------------------------
>
> In nan.h <#1026 (comment)>
> :
>
> > @@ -660,6 +660,12 @@ class AsyncResource {
> #endif
> }
>
> +#if NODE_MODULE_VERSION >= NODE_9_0_MODULE_VERSION
> + inline node::CallbackScope makeCallbackScope(v8::Local<v8::Object> target) {
> + return {v8::Isolate::GetCurrent(), target, context};
> + }
> +#endif
>
> So the proposal is to add an #error in this case.
>
> The rationale is that this is something modules will have to add now in
> order to work correctly on Node 26+, while dropping support for Node 8 and
> earlier.
>
> Anyway, I am afraid that there is no way to safely implement this on Node
> 8 - this was before Promise was common and all C++ modules used
> callbacks which do not have this problem.
>
> —
> Reply to this email directly, view it on GitHub
> <#1026?email_source=notifications&email_token=AA7JXKLND3MADKXDP6SCJBL5UIA3BA5CNFSNUABKM5UWIORPF5TWS5BNNB2WEL2QOVWGYUTFOF2WK43UKJSXM2LFO4XTKNJUG4YTINZXG422M4TFMFZW63VHMNXW23LFNZ2KKZLWMVXHJLDGN5XXIZLSL5RWY2LDNM#discussion_r4294158752>,
> or unsubscribe
> <https://github.com/notifications/unsubscribe-auth/AA7JXKMOLAUGJ22NTG4LPH35UIA3BAVCNFSNUABEKJSXA33TNF2G64TZHMYTCNJUGU4TEOB3JFZXG5LFHM2TKNJTGU3TIOJZGCQXMAQ>
> .
> Triage notifications, keep track of coding agent tasks and review pull
> requests on the go with GitHub Mobile for iOS
> <https://github.com/notifications/mobile/ios/AA7JXKOQ6QEVOH3UAOOEC5L5UIA3BA5CNFSNUABKM5UWIORPF5TWS5BNNB2WEL2QOVWGYUTFOF2WK43UKJSXM2LFO4XTKNJUG4YTINZXG422M4TFMFZW63VHMNXW23LFNZ2KKZLWMVXHJKTGN5XXIZLSL5UW64Y>
> and Android
> <https://github.com/notifications/mobile/android/AA7JXKM4GUYPZWUGZTLOHAD5UIA3BA5CNFSNUABKM5UWIORPF5TWS5BNNB2WEL2QOVWGYUTFOF2WK43UKJSXM2LFO4XTKNJUG4YTINZXG422M4TFMFZW63VHMNXW23LFNZ2KKZLWMVXHJLTGN5XXIZLSL5QW4ZDSN5UWI>.
> Download it today!
> You are receiving this because you commented.Message ID:
> ***@***.***>
>
|
|
actually, it would probably be enough to just ifdef the async resource
declaration. If it gets used and node version is too low, it will cause a
compilation error, good enough
…On Fri, Oct 16, 2026, 14:52 Benjamin Byholm ***@***.***> wrote:
```
template<int E>
struct Foo {
char b[2*E-1];
};
/* usage */
Foo<(int)(NODE_MOD_VER > 123)> assertion;
```
Something along those lines. I can make an actual implementation tomorrow
if that helps.
On Fri, Oct 16, 2026, 14:38 Benjamin Byholm ***@***.***> wrote:
> I would prefer the rest of NAN to still be usable on those ancient
> versions, as long as one does not try to actually use async resources.
>
>
> On Fri, Oct 16, 2026, 14:27 Momtchil Momtchev ***@***.***>
> wrote:
>
>> ***@***.**** commented on this pull request.
>> ------------------------------
>>
>> In nan.h
>> <#1026 (comment)>:
>>
>> > @@ -660,6 +660,12 @@ class AsyncResource {
>> #endif
>> }
>>
>> +#if NODE_MODULE_VERSION >= NODE_9_0_MODULE_VERSION
>> + inline node::CallbackScope makeCallbackScope(v8::Local<v8::Object> target) {
>> + return {v8::Isolate::GetCurrent(), target, context};
>> + }
>> +#endif
>>
>> So the proposal is to add an #error in this case.
>>
>> The rationale is that this is something modules will have to add now in
>> order to work correctly on Node 26+, while dropping support for Node 8 and
>> earlier.
>>
>> Anyway, I am afraid that there is no way to safely implement this on
>> Node 8 - this was before Promise was common and all C++ modules used
>> callbacks which do not have this problem.
>>
>> —
>> Reply to this email directly, view it on GitHub
>> <#1026?email_source=notifications&email_token=AA7JXKLND3MADKXDP6SCJBL5UIA3BA5CNFSNUABKM5UWIORPF5TWS5BNNB2WEL2QOVWGYUTFOF2WK43UKJSXM2LFO4XTKNJUG4YTINZXG422M4TFMFZW63VHMNXW23LFNZ2KKZLWMVXHJLDGN5XXIZLSL5RWY2LDNM#discussion_r4294158752>,
>> or unsubscribe
>> <https://github.com/notifications/unsubscribe-auth/AA7JXKMOLAUGJ22NTG4LPH35UIA3BAVCNFSNUABEKJSXA33TNF2G64TZHMYTCNJUGU4TEOB3JFZXG5LFHM2TKNJTGU3TIOJZGCQXMAQ>
>> .
>> Triage notifications, keep track of coding agent tasks and review pull
>> requests on the go with GitHub Mobile for iOS
>> <https://github.com/notifications/mobile/ios/AA7JXKOQ6QEVOH3UAOOEC5L5UIA3BA5CNFSNUABKM5UWIORPF5TWS5BNNB2WEL2QOVWGYUTFOF2WK43UKJSXM2LFO4XTKNJUG4YTINZXG422M4TFMFZW63VHMNXW23LFNZ2KKZLWMVXHJKTGN5XXIZLSL5UW64Y>
>> and Android
>> <https://github.com/notifications/mobile/android/AA7JXKM4GUYPZWUGZTLOHAD5UIA3BA5CNFSNUABKM5UWIORPF5TWS5BNNB2WEL2QOVWGYUTFOF2WK43UKJSXM2LFO4XTKNJUG4YTINZXG422M4TFMFZW63VHMNXW23LFNZ2KKZLWMVXHJLTGN5XXIZLSL5QW4ZDSN5UWI>.
>> Download it today!
>> You are receiving this because you commented.Message ID:
>> ***@***.***>
>>
>
|
|
Why not just an |
|
In fact, if the goal is to emit an error only if the code is actually used, the best way is to simply omit the function when it is not there. This way code that uses it won't compile on older Node versions. |
|
This will print the line: #if NODE_MODULE_VERSION >= NODE_9_0_MODULE_VERSION
inline operator node::async_context() const {
return context;
}
#else
inline operator node::async_context() = delete; // Not supported before Node 9
#endif |
|
Default deleted constructors are C++11, sadly only acceptable for Node 4 and later, otherwise elegant. I did a slightly more fleshed out version of the SFINAE thing, not sure if it can be made finer than the whole |
|
The goal would be to have code using the next release of NAN still compile on ancient versions, as long as |
|
Okay, did some further testing. Just not having the explicit delete there gives a nice error about the conversion operator not existing, which is good enough. So, I think this should suffice: Seems to do what it should with all permutations of |
|
Actually, the branch for NODE_MODULE_VERSION >= 4 should better be a test for CXX11. |
|
Or just leave said branch out to avoid the ugly hack in node namespace, that is probably nicer. |
|
If you simply omit the function with an |
|
I agree, that is what I concluded in my last message. So it would end up like this: |
Refs: #1024
Allow retrieving the
node::async_contextfromNan::AsyncResroucein order to constructnode::CallbackScope.The problem is that the
node::async_contextis a private member ofnan::AsyncResource.This allows to run properly the microtasks queue for async workers that do not call JavaScript.
This require Node.js 9.0.0, as before this version the microtasks queue was always run automatically.
In reality, Node.js 26.4.0 is the first version that actually does not do this, although this has been specified since Node.js 9.0.0.