Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 606523d

Browse filesBrowse files
legendecastargos
authored andcommitted
v8: fix ERR_NOT_BUILDING_SNAPSHOT is not a constructor
PR-URL: #47721 Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: Tobias Nießen <tniessen@tnie.de>
1 parent e948bec commit 606523d
Copy full SHA for 606523d

File tree

Expand file treeCollapse file tree

3 files changed

+35
-2
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

3 files changed

+35
-2
lines changed
Open diff view settings
Collapse file

‎lib/internal/v8/startup_snapshot.js‎

Copy file name to clipboardExpand all lines: lib/internal/v8/startup_snapshot.js
+4-2Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,10 @@ const {
44
validateFunction,
55
} = require('internal/validators');
66
const {
7-
ERR_NOT_BUILDING_SNAPSHOT,
8-
ERR_DUPLICATE_STARTUP_SNAPSHOT_MAIN_FUNCTION,
7+
codes: {
8+
ERR_NOT_BUILDING_SNAPSHOT,
9+
ERR_DUPLICATE_STARTUP_SNAPSHOT_MAIN_FUNCTION,
10+
},
911
} = require('internal/errors');
1012

1113
const {
Collapse file

‎test/fixtures/snapshot/v8-startup-snapshot-api.js‎

Copy file name to clipboardExpand all lines: test/fixtures/snapshot/v8-startup-snapshot-api.js
+5Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,8 @@ addDeserializeCallback(({ filePath }) => {
3030
setDeserializeMainFunction(({ filePath }) => {
3131
console.log(storage[filePath].toString());
3232
}, { filePath });
33+
assert.throws(() => setDeserializeMainFunction(() => {
34+
assert.fail('unreachable duplicated main function');
35+
}), {
36+
code: 'ERR_DUPLICATE_STARTUP_SNAPSHOT_MAIN_FUNCTION',
37+
});
Collapse file
+26Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
'use strict';
2+
3+
require('../common');
4+
const assert = require('assert');
5+
6+
const {
7+
isBuildingSnapshot,
8+
addSerializeCallback,
9+
addDeserializeCallback,
10+
setDeserializeMainFunction
11+
} = require('v8').startupSnapshot;
12+
13+
// This test verifies that the v8.startupSnapshot APIs are not available when
14+
// it is not building snapshot.
15+
16+
assert(!isBuildingSnapshot());
17+
18+
assert.throws(() => addSerializeCallback(() => {}), {
19+
code: 'ERR_NOT_BUILDING_SNAPSHOT',
20+
});
21+
assert.throws(() => addDeserializeCallback(() => {}), {
22+
code: 'ERR_NOT_BUILDING_SNAPSHOT',
23+
});
24+
assert.throws(() => setDeserializeMainFunction(() => {}), {
25+
code: 'ERR_NOT_BUILDING_SNAPSHOT',
26+
});

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.