From efb32592e1b78ec2559e1a409faa049e756a9501 Mon Sep 17 00:00:00 2001 From: Ali Ijaz Sheikh Date: Wed, 24 Jan 2018 18:09:53 -0800 Subject: [PATCH] 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: https://github.com/nodejs/node/issues/13254 PR-URL: https://github.com/nodejs/node/pull/18632 Reviewed-By: Colin Ihrig Reviewed-By: Evan Lucas Reviewed-By: Jan Krems Reviewed-By: Andreas Madsen Reviewed-By: Anna Henningsen Reviewed-By: Gibson Fahnestock --- doc/api/deprecations.md | 9 +++++++++ src/node.h | 41 ++++++++++++++++++++++------------------- 2 files changed, 31 insertions(+), 19 deletions(-) diff --git a/doc/api/deprecations.md b/doc/api/deprecations.md index c0778aebadbd36..d1751cdff66180 100644 --- a/doc/api/deprecations.md +++ b/doc/api/deprecations.md @@ -893,6 +893,15 @@ Use [`asyncResource.runInAsyncScope()`][] API instead which provides a much safer, and more convenient, alternative. See https://github.com/nodejs/node/pull/18513 for more details. + +### DEP0098: async context-unaware node::MakeCallback C++ APIs + +Type: Compile-time + +Certain versions of `node::MakeCallback` APIs available to native modules are +deprecated. Please use the versions of the API that accept an `async_context` +parameter. + [`--pending-deprecation`]: cli.html#cli_pending_deprecation [`Buffer.allocUnsafeSlow(size)`]: buffer.html#buffer_class_method_buffer_allocunsafeslow_size [`Buffer.from(array)`]: buffer.html#buffer_class_method_buffer_from_array diff --git a/src/node.h b/src/node.h index 89dbdfc727b0c5..cb4346893014ef 100644 --- a/src/node.h +++ b/src/node.h @@ -151,27 +151,30 @@ inline v8::Local UVException(int errorno, * These methods need to be called in a HandleScope. * * It is preferred that you use the `MakeCallback` overloads taking - * `async_id` arguments. + * `async_context` arguments. */ -NODE_EXTERN v8::Local MakeCallback( - v8::Isolate* isolate, - v8::Local recv, - const char* method, - int argc, - v8::Local* argv); -NODE_EXTERN v8::Local MakeCallback( - v8::Isolate* isolate, - v8::Local recv, - v8::Local symbol, - int argc, - v8::Local* argv); -NODE_EXTERN v8::Local MakeCallback( - v8::Isolate* isolate, - v8::Local recv, - v8::Local callback, - int argc, - v8::Local* argv); +NODE_DEPRECATED("Use MakeCallback(..., async_context)", + NODE_EXTERN v8::Local MakeCallback( + v8::Isolate* isolate, + v8::Local recv, + const char* method, + int argc, + v8::Local* argv)); +NODE_DEPRECATED("Use MakeCallback(..., async_context)", + NODE_EXTERN v8::Local MakeCallback( + v8::Isolate* isolate, + v8::Local recv, + v8::Local symbol, + int argc, + v8::Local* argv)); +NODE_DEPRECATED("Use MakeCallback(..., async_context)", + NODE_EXTERN v8::Local MakeCallback( + v8::Isolate* isolate, + v8::Local recv, + v8::Local callback, + int argc, + v8::Local* argv)); } // namespace node