Movatterモバイル変換


[0]ホーム

URL:


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

Sign up
Appearance settings

Commit7595e1f

Browse files
josephperrottjkrems
authored andcommitted
fix(@angular-devkit/core): use crypto.randomUUID instead of Date.now for unique string in tmp file names
Use crypto.randomUUID instead of Date.now for unique string in the tmpdir path name for a TempScopedNodeJsSyncHost to prevent naming conflicts.When performaning tests on a fast enough machine which rely on this class, two instances can be instantiated within one second and cancause failures because the path already exists that is attempted to be used. Using crypto.randomUUID should not run into this issue.
1 parent3cd73d3 commit7595e1f

File tree

1 file changed

+4
-1
lines changed
  • packages/angular_devkit/core/node/testing

1 file changed

+4
-1
lines changed

‎packages/angular_devkit/core/node/testing/index.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
* found in the LICENSE file at https://angular.dev/license
77
*/
88

9+
import*ascryptofrom'node:crypto';
910
import*asfsfrom'node:fs';
1011
import*asosfrom'node:os';
1112
import*aspathfrom'node:path';
@@ -20,7 +21,9 @@ export class TempScopedNodeJsSyncHost extends virtualFs.ScopedHost<fs.Stats> {
2021
protectedoverride_root:Path;
2122

2223
constructor(){
23-
constroot=normalize(path.join(os.tmpdir(),`devkit-host-${+Date.now()}-${process.pid}`));
24+
constroot=normalize(
25+
path.join(os.tmpdir(),`devkit-host-${crypto.randomUUID()}-${process.pid}`),
26+
);
2427
fs.mkdirSync(getSystemPath(root));
2528

2629
super(newNodeJsSyncHost(),root);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp