mirror of
https://github.com/nodejs/node.git
synced 2024-11-21 10:59:27 +00:00
v8: fix ERR_NOT_BUILDING_SNAPSHOT is not a constructor
PR-URL: https://github.com/nodejs/node/pull/47721 Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: Tobias Nießen <tniessen@tnie.de>
This commit is contained in:
parent
4c62042774
commit
bddf341774
@ -4,8 +4,10 @@ const {
|
||||
validateFunction,
|
||||
} = require('internal/validators');
|
||||
const {
|
||||
ERR_NOT_BUILDING_SNAPSHOT,
|
||||
ERR_DUPLICATE_STARTUP_SNAPSHOT_MAIN_FUNCTION,
|
||||
codes: {
|
||||
ERR_NOT_BUILDING_SNAPSHOT,
|
||||
ERR_DUPLICATE_STARTUP_SNAPSHOT_MAIN_FUNCTION,
|
||||
},
|
||||
} = require('internal/errors');
|
||||
|
||||
const {
|
||||
|
@ -30,3 +30,8 @@ addDeserializeCallback(({ filePath }) => {
|
||||
setDeserializeMainFunction(({ filePath }) => {
|
||||
console.log(storage[filePath].toString());
|
||||
}, { filePath });
|
||||
assert.throws(() => setDeserializeMainFunction(() => {
|
||||
assert.fail('unreachable duplicated main function');
|
||||
}), {
|
||||
code: 'ERR_DUPLICATE_STARTUP_SNAPSHOT_MAIN_FUNCTION',
|
||||
});
|
||||
|
26
test/parallel/test-v8-startup-snapshot-api.js
Normal file
26
test/parallel/test-v8-startup-snapshot-api.js
Normal file
@ -0,0 +1,26 @@
|
||||
'use strict';
|
||||
|
||||
require('../common');
|
||||
const assert = require('assert');
|
||||
|
||||
const {
|
||||
isBuildingSnapshot,
|
||||
addSerializeCallback,
|
||||
addDeserializeCallback,
|
||||
setDeserializeMainFunction
|
||||
} = require('v8').startupSnapshot;
|
||||
|
||||
// This test verifies that the v8.startupSnapshot APIs are not available when
|
||||
// it is not building snapshot.
|
||||
|
||||
assert(!isBuildingSnapshot());
|
||||
|
||||
assert.throws(() => addSerializeCallback(() => {}), {
|
||||
code: 'ERR_NOT_BUILDING_SNAPSHOT',
|
||||
});
|
||||
assert.throws(() => addDeserializeCallback(() => {}), {
|
||||
code: 'ERR_NOT_BUILDING_SNAPSHOT',
|
||||
});
|
||||
assert.throws(() => setDeserializeMainFunction(() => {}), {
|
||||
code: 'ERR_NOT_BUILDING_SNAPSHOT',
|
||||
});
|
Loading…
Reference in New Issue
Block a user