Skip to content

Commit efb3259

Browse files
committed
src: deprecate legacy node::MakeCallback
The legacy MakeCallback functions do not provide a mechanism to propagate async context. This means that any native modules using these directly is likely breaking async debugging & tracing tools. For example it is possible that such a module will cause incorrect async stack traces to be reported (even when the module is not on the stack). The new MakeCallback allow the user to specify the async context in which the callback is to be executed. Ref: #13254 PR-URL: #18632 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Evan Lucas <evanlucas@me.com> Reviewed-By: Jan Krems <jan.krems@gmail.com> Reviewed-By: Andreas Madsen <amwebdk@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com>
1 parent 3b9cc42 commit efb3259

File tree

2 files changed

+31
-19
lines changed

2 files changed

+31
-19
lines changed

doc/api/deprecations.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -893,6 +893,15 @@ Use [`asyncResource.runInAsyncScope()`][] API instead which provides a much
893893
safer, and more convenient, alternative. See
894894
https://github.com/nodejs/node/pull/18513 for more details.
895895
896+
<a id="DEP0098"></a>
897+
### DEP0098: async context-unaware node::MakeCallback C++ APIs
898+
899+
Type: Compile-time
900+
901+
Certain versions of `node::MakeCallback` APIs available to native modules are
902+
deprecated. Please use the versions of the API that accept an `async_context`
903+
parameter.
904+
896905
[`--pending-deprecation`]: cli.html#cli_pending_deprecation
897906
[`Buffer.allocUnsafeSlow(size)`]: buffer.html#buffer_class_method_buffer_allocunsafeslow_size
898907
[`Buffer.from(array)`]: buffer.html#buffer_class_method_buffer_from_array

src/node.h

Lines changed: 22 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -151,27 +151,30 @@ inline v8::Local<v8::Value> UVException(int errorno,
151151
* These methods need to be called in a HandleScope.
152152
*
153153
* It is preferred that you use the `MakeCallback` overloads taking
154-
* `async_id` arguments.
154+
* `async_context` arguments.
155155
*/
156156

157-
NODE_EXTERN v8::Local<v8::Value> MakeCallback(
158-
v8::Isolate* isolate,
159-
v8::Local<v8::Object> recv,
160-
const char* method,
161-
int argc,
162-
v8::Local<v8::Value>* argv);
163-
NODE_EXTERN v8::Local<v8::Value> MakeCallback(
164-
v8::Isolate* isolate,
165-
v8::Local<v8::Object> recv,
166-
v8::Local<v8::String> symbol,
167-
int argc,
168-
v8::Local<v8::Value>* argv);
169-
NODE_EXTERN v8::Local<v8::Value> MakeCallback(
170-
v8::Isolate* isolate,
171-
v8::Local<v8::Object> recv,
172-
v8::Local<v8::Function> callback,
173-
int argc,
174-
v8::Local<v8::Value>* argv);
157+
NODE_DEPRECATED("Use MakeCallback(..., async_context)",
158+
NODE_EXTERN v8::Local<v8::Value> MakeCallback(
159+
v8::Isolate* isolate,
160+
v8::Local<v8::Object> recv,
161+
const char* method,
162+
int argc,
163+
v8::Local<v8::Value>* argv));
164+
NODE_DEPRECATED("Use MakeCallback(..., async_context)",
165+
NODE_EXTERN v8::Local<v8::Value> MakeCallback(
166+
v8::Isolate* isolate,
167+
v8::Local<v8::Object> recv,
168+
v8::Local<v8::String> symbol,
169+
int argc,
170+
v8::Local<v8::Value>* argv));
171+
NODE_DEPRECATED("Use MakeCallback(..., async_context)",
172+
NODE_EXTERN v8::Local<v8::Value> MakeCallback(
173+
v8::Isolate* isolate,
174+
v8::Local<v8::Object> recv,
175+
v8::Local<v8::Function> callback,
176+
int argc,
177+
v8::Local<v8::Value>* argv));
175178

176179
} // namespace node
177180

0 commit comments

Comments
 (0)