From 82db6729915e031814425360d2b8e7c83328697d Mon Sep 17 00:00:00 2001 From: Ujjwal Sharma Date: Thu, 7 Jun 2018 22:51:47 +0530 Subject: [PATCH] v8: replace Buffer with FastBuffer in deserialize Replace the Buffer constructor with a FastBuffer in v8.deserialize in order to avoid calling the Buffer constructor and thus triggering a deprecation warning from code inside the core. Fixes: https://github.com/nodejs/node/issues/21181 PR-URL: https://github.com/nodejs/node/pull/21196 Fixes: https://github.com/nodejs/node/issues/21181 Reviewed-By: Anna Henningsen Reviewed-By: Trivikram Kamat Reviewed-By: Gus Caplan Reviewed-By: Luigi Pinca Reviewed-By: Tiancheng "Timothy" Gu Reviewed-By: James M Snell --- lib/v8.js | 2 +- test/parallel/test-v8-deserialize-buffer.js | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) create mode 100644 test/parallel/test-v8-deserialize-buffer.js diff --git a/lib/v8.js b/lib/v8.js index ed93b094ca7895..0d9ffc6033ced2 100644 --- a/lib/v8.js +++ b/lib/v8.js @@ -143,7 +143,7 @@ const arrayBufferViewTypeToIndex = new Map(); } } -const bufferConstructorIndex = arrayBufferViewTypes.push(Buffer) - 1; +const bufferConstructorIndex = arrayBufferViewTypes.push(FastBuffer) - 1; class DefaultSerializer extends Serializer { constructor() { diff --git a/test/parallel/test-v8-deserialize-buffer.js b/test/parallel/test-v8-deserialize-buffer.js new file mode 100644 index 00000000000000..b6438027bafbfd --- /dev/null +++ b/test/parallel/test-v8-deserialize-buffer.js @@ -0,0 +1,8 @@ +// Flags: --pending-deprecation --no-warnings +'use strict'; + +const common = require('../common'); +const v8 = require('v8'); + +process.on('warning', common.mustNotCall()); +v8.deserialize(v8.serialize(Buffer.alloc(0)));