From 659e9cfb592cd109edeee2f86d291e6ba0ccc72e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A1=D0=BA=D0=BE=D0=B2=D0=BE=D1=80=D0=BE=D0=B4=D0=B0=20?= =?UTF-8?q?=D0=9D=D0=B8=D0=BA=D0=B8=D1=82=D0=B0=20=D0=90=D0=BD=D0=B4=D1=80?= =?UTF-8?q?=D0=B5=D0=B5=D0=B2=D0=B8=D1=87?= Date: Wed, 29 Aug 2018 18:44:02 +0300 Subject: [PATCH] [WiP] buffer: runtime-deprecate buffer constructor in sync mode --- lib/buffer.js | 1 + lib/internal/process/next_tick.js | 3 +++ 2 files changed, 4 insertions(+) diff --git a/lib/buffer.js b/lib/buffer.js index e025b322f0c791..27e2e1c6b2cd78 100644 --- a/lib/buffer.js +++ b/lib/buffer.js @@ -147,6 +147,7 @@ function showFlaggedDeprecation() { if (bufferWarningAlreadyEmitted || ++nodeModulesCheckCounter > 10000 || (!pendingDeprecation && + !process.stillSynchronous && isInsideNodeModules())) { // We don't emit a warning, because we either: // - Already did so, or diff --git a/lib/internal/process/next_tick.js b/lib/internal/process/next_tick.js index df6984aabc8c07..c78c4039a619b4 100644 --- a/lib/internal/process/next_tick.js +++ b/lib/internal/process/next_tick.js @@ -116,4 +116,7 @@ function setupNextTick(_setupNextTick, _setupPromises) { tickInfo[kHasScheduled] = 1; queue.push(new TickObject(callback, args, getDefaultTriggerAsyncId())); } + + process.stillSynchronous = true; + process.nextTick(() => { process.stillSynchronous = false; }); }