Skip to content

Commit

Permalink
v8: replace Buffer with FastBuffer in deserialize
Browse files Browse the repository at this point in the history
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: #21181

PR-URL: #21196
Fixes: #21181
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
Reviewed-By: Gus Caplan <me@gus.host>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
  • Loading branch information
ryzokuken authored and targos committed Jun 14, 2018
1 parent 13fd09b commit d46446a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/v8.js
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
8 changes: 8 additions & 0 deletions test/parallel/test-v8-deserialize-buffer.js
Original file line number Diff line number Diff line change
@@ -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)));

0 comments on commit d46446a

Please sign in to comment.