Skip to content

Commit 9892444

Browse files
authored
2 parents 77f0f84 + 68d232f commit 9892444

File tree

19 files changed

+837
-701
lines changed

19 files changed

+837
-701
lines changed

.github/workflows/close-stale-issues.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jobs:
1212
runs-on: ubuntu-latest
1313
name: Stale issue job
1414
steps:
15-
- uses: aws-actions/stale-issue-cleanup@v5
15+
- uses: aws-actions/stale-issue-cleanup@v6
1616
with:
1717
# Setting messages to an empty string will cause the automation to skip
1818
# that category

.github/workflows/docker-images.yml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,12 @@ jobs:
2323
matrix:
2424
debian:
2525
- 'buster' # 10
26-
- 'bullseye' # 11
27-
- 'bookworm' # 12
28-
node: ['14', '16', '18', '20']
26+
node: ['16', '18', '20']
27+
include:
28+
- debian: 'bullseye' # 11
29+
node: '20'
30+
- debian: 'bookworm' #12
31+
node: '20'
2932
env:
3033
# Node version whose images will be aliased without the -nodeXX segment
3134
DEFAULT_NODE_MAJOR_VERSION: 16

CHANGELOG.md

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,23 @@
22

33
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
44

5+
## [1.87.0](https://github.com/aws/jsii/compare/v1.86.1...v1.87.0) (2023-08-11)
6+
7+
8+
### Bug Fixes
9+
10+
* **kernel:** fast module loading fails on Windows (EPERM) ([#4212](https://github.com/aws/jsii/issues/4212)) ([fac6cbb](https://github.com/aws/jsii/commit/fac6cbbeb5d9bcbbac8f9dff58001afb701a4065)), closes [#4208](https://github.com/aws/jsii/issues/4208)
11+
* **kernel:** package cache fails under parallelism ([#4215](https://github.com/aws/jsii/issues/4215)) ([b739ef6](https://github.com/aws/jsii/commit/b739ef68d4d92d7af78b2a91b8581e9f3077df96)), closes [#4181](https://github.com/aws/jsii/issues/4181) [#4207](https://github.com/aws/jsii/issues/4207)
12+
* pip, black, setuptools, twine, wheel, and aws-sam-cli incorrectly installed in superchain ([#4201](https://github.com/aws/jsii/issues/4201)) ([851415c](https://github.com/aws/jsii/commit/851415c44864c0fb0b4b2d5ee4535f0b33f89a48))
13+
* **python:** type object 'InterfaceDynamicProxy' has no attribute '__jsii_type__' ([#4209](https://github.com/aws/jsii/issues/4209)) ([057b267](https://github.com/aws/jsii/commit/057b267809a05135d6d22227318ae55100aad272))
14+
* **superchain:** add openssh-client back ([#4224](https://github.com/aws/jsii/issues/4224)) ([8390ca1](https://github.com/aws/jsii/commit/8390ca1615769846f92c42ef35ac590b4673efbb))
15+
516
## [1.86.1](https://github.com/aws/jsii/compare/v1.86.0...v1.86.1) (2023-08-02)
617

718

819
### Bug Fixes
920

10-
* **kernel:** incorrectly scoped FQN resolutions ([#4204](https://github.com/aws/jsii/pull/4204)) ([ed667c7](https://github.com/aws/jsii/commit/ed667c76be73c43f969a1b7acc0b4b93a7a00889))
21+
* **kernel:** incorrectly scoped FQN resolutions ([#4204](https://github.com/aws/jsii/issues/4204)) ([ed667c7](https://github.com/aws/jsii/commit/ed667c76be73c43f969a1b7acc0b4b93a7a00889)), closes [aws/aws-cdk#26604](https://github.com/aws/aws-cdk/issues/26604) [#4202](https://github.com/aws/jsii/issues/4202) [#4203](https://github.com/aws/jsii/issues/4203)
1122

1223
## [1.86.0](https://github.com/aws/jsii/compare/v1.85.0...v1.86.0) (2023-08-01)
1324

lerna.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,6 @@
1212
"rejectCycles": true
1313
}
1414
},
15-
"version": "1.86.1",
15+
"version": "1.87.0",
1616
"$schema": "node_modules/lerna/schemas/lerna-schema.json"
1717
}

package.json

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,21 +18,21 @@
1818
"@jest/types": "^28.1.3",
1919
"@types/jest": "^29.5.3",
2020
"@types/node": "^14.18.54",
21-
"@typescript-eslint/eslint-plugin": "^6.2.0",
22-
"@typescript-eslint/parser": "^6.2.0",
21+
"@typescript-eslint/eslint-plugin": "^6.3.0",
22+
"@typescript-eslint/parser": "^6.3.0",
2323
"all-contributors-cli": "^6.26.1",
24-
"eslint": "^8.45.0",
25-
"eslint-config-prettier": "^8.8.0",
26-
"eslint-import-resolver-node": "^0.3.7",
24+
"eslint": "^8.46.0",
25+
"eslint-config-prettier": "^9.0.0",
26+
"eslint-import-resolver-node": "^0.3.9",
2727
"eslint-import-resolver-typescript": "^3.5.5",
2828
"eslint-plugin-import": "2.26.0",
2929
"eslint-plugin-prettier": "^5.0.0",
30-
"jest": "^29.6.1",
30+
"jest": "^29.6.2",
3131
"jest-circus": "^28.1.3",
3232
"jest-config": "^28.1.3",
3333
"jest-expect-message": "^1.1.3",
3434
"lerna": "^7.1.4",
35-
"prettier": "^3.0.0",
35+
"prettier": "^3.0.1",
3636
"standard-version": "^9.5.0",
3737
"ts-node": "^10.9.1",
3838
"typescript": "~4.7.4"

packages/@jsii/go-runtime-test/project/go.mod

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ require (
99
github.com/aws/jsii/jsii-calc/go/scopejsiicalclib v0.0.0-devpreview
1010
github.com/stretchr/testify v1.8.4
1111
golang.org/x/lint v0.0.0-20210508222113-6edffad5e616
12-
golang.org/x/tools v0.11.0
12+
golang.org/x/tools v0.12.0
1313
)
1414

1515
require (
@@ -22,7 +22,7 @@ require (
2222
github.com/pmezard/go-difflib v1.0.0 // indirect
2323
github.com/yuin/goldmark v1.4.13 // indirect
2424
golang.org/x/mod v0.12.0 // indirect
25-
golang.org/x/sys v0.10.0 // indirect
25+
golang.org/x/sys v0.11.0 // indirect
2626
gopkg.in/yaml.v3 v3.0.1 // indirect
2727
)
2828

packages/@jsii/go-runtime-test/project/go.sum

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ golang.org/x/sys v0.9.0 h1:KS/R3tvhPqvJvwcKfnBHJwwthS11LRhmM5D59eEXa0s=
4141
golang.org/x/sys v0.9.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
4242
golang.org/x/sys v0.10.0 h1:SqMFp9UcQJZa+pmYuAKjd9xq1f0j5rLcDIk0mj4qAsA=
4343
golang.org/x/sys v0.10.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
44+
golang.org/x/sys v0.11.0 h1:eG7RXZHdqOJ1i+0lgLgCpSXAp6M3LYlAo6osgSi0xOM=
45+
golang.org/x/sys v0.11.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
4446
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
4547
golang.org/x/tools v0.0.0-20200130002326-2f3ba24bd6e7/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
4648
golang.org/x/tools v0.9.3 h1:Gn1I8+64MsuTb/HpH+LmQtNas23LhUVr3rYZ0eKuaMM=
@@ -49,6 +51,8 @@ golang.org/x/tools v0.10.0 h1:tvDr/iQoUqNdohiYm0LmmKcBk+q86lb9EprIUFhHHGg=
4951
golang.org/x/tools v0.10.0/go.mod h1:UJwyiVBsOA2uwvK/e5OY3GTpDUJriEd+/YlqAwLPmyM=
5052
golang.org/x/tools v0.11.0 h1:EMCa6U9S2LtZXLAMoWiR/R8dAQFRqbAitmbJ2UKhoi8=
5153
golang.org/x/tools v0.11.0/go.mod h1:anzJrxPjNtfgiYQYirP2CPGzGLxrH2u2QBhn6Bf3qY8=
54+
golang.org/x/tools v0.12.0 h1:YW6HUoUmYBpwSgyaGaZq1fHjrBjX1rlpZ54T6mu2kss=
55+
golang.org/x/tools v0.12.0/go.mod h1:Sc0INKfu04TlqNoRA1hgpFZbhYXHPr4V5DzpSBTPqQM=
5256
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
5357
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
5458
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=

packages/@jsii/go-runtime/jsii-runtime-go/go.mod

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ require (
88
github.com/mattn/go-isatty v0.0.19
99
github.com/stretchr/testify v1.8.4
1010
golang.org/x/lint v0.0.0-20210508222113-6edffad5e616
11-
golang.org/x/tools v0.11.0
11+
golang.org/x/tools v0.12.0
1212
)
1313

1414
require (
@@ -17,7 +17,7 @@ require (
1717
github.com/pmezard/go-difflib v1.0.0 // indirect
1818
github.com/yuin/goldmark v1.4.13 // indirect
1919
golang.org/x/mod v0.12.0 // indirect
20-
golang.org/x/sys v0.10.0 // indirect
20+
golang.org/x/sys v0.11.0 // indirect
2121
gopkg.in/yaml.v3 v3.0.1 // indirect
2222
)
2323

packages/@jsii/go-runtime/jsii-runtime-go/go.sum

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,12 @@ golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5h
3030
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
3131
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
3232
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
33-
golang.org/x/sys v0.10.0 h1:SqMFp9UcQJZa+pmYuAKjd9xq1f0j5rLcDIk0mj4qAsA=
34-
golang.org/x/sys v0.10.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
33+
golang.org/x/sys v0.11.0 h1:eG7RXZHdqOJ1i+0lgLgCpSXAp6M3LYlAo6osgSi0xOM=
34+
golang.org/x/sys v0.11.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
3535
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
3636
golang.org/x/tools v0.0.0-20200130002326-2f3ba24bd6e7/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
37-
golang.org/x/tools v0.11.0 h1:EMCa6U9S2LtZXLAMoWiR/R8dAQFRqbAitmbJ2UKhoi8=
38-
golang.org/x/tools v0.11.0/go.mod h1:anzJrxPjNtfgiYQYirP2CPGzGLxrH2u2QBhn6Bf3qY8=
37+
golang.org/x/tools v0.12.0 h1:YW6HUoUmYBpwSgyaGaZq1fHjrBjX1rlpZ54T6mu2kss=
38+
golang.org/x/tools v0.12.0/go.mod h1:Sc0INKfu04TlqNoRA1hgpFZbhYXHPr4V5DzpSBTPqQM=
3939
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
4040
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
4141
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=

packages/@jsii/kernel/src/disk-cache/disk-cache.ts

Lines changed: 122 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import {
1010
utimesSync,
1111
writeFileSync,
1212
} from 'fs';
13-
import { lockSync, unlockSync } from 'lockfile';
13+
import { lockSync, Options, unlockSync } from 'lockfile';
1414
import { dirname, join } from 'path';
1515

1616
import { digestFile } from './digest-file';
@@ -152,9 +152,62 @@ export class Entry {
152152
return join(this.path, MARKER_FILE_NAME);
153153
}
154154

155+
/**
156+
* Whether the directory has been completely written
157+
*
158+
* The presence of the marker file is a signal that we can skip trying to lock the directory.
159+
*/
160+
public get isComplete(): boolean {
161+
return existsSync(this.#markerFile);
162+
}
163+
164+
/**
165+
* Retrieve an entry from the cache
166+
*
167+
* If the entry doesn't exist yet, use 'cb' to produce the file contents.
168+
*/
169+
public retrieve(cb: (path: string) => void): {
170+
path: string;
171+
cache: 'hit' | 'miss';
172+
} {
173+
// If the marker file already exists, update its timestamp and immediately return.
174+
// We don't even try to lock.
175+
if (this.isComplete) {
176+
this.#touchMarkerFile();
177+
return { path: this.path, cache: 'hit' };
178+
}
179+
180+
let cache: 'hit' | 'miss' = 'miss';
181+
this.lock((lock) => {
182+
// While we all fought to acquire the lock, someone else might have completed already.
183+
if (this.isComplete) {
184+
cache = 'hit';
185+
return;
186+
}
187+
188+
// !!!IMPORTANT!!!
189+
// Extract directly into the final target directory, as certain antivirus
190+
// software configurations on Windows will make a `renameSync` operation
191+
// fail with EPERM until the files have been fully analyzed.
192+
mkdirSync(this.path, { recursive: true });
193+
try {
194+
cb(this.path);
195+
} catch (error) {
196+
rmSync(this.path, { force: true, recursive: true });
197+
throw error;
198+
}
199+
lock.markComplete();
200+
});
201+
return { path: this.path, cache };
202+
}
203+
155204
public lock<T>(cb: (entry: LockedEntry) => T): T {
156205
mkdirSync(dirname(this.path), { recursive: true });
157-
lockSync(this.#lockFile, { retries: 12, stale: 5_000 });
206+
lockSyncWithWait(this.#lockFile, {
207+
retries: 12,
208+
// Extracting the largest tarball takes ~5s
209+
stale: 10_000,
210+
});
158211
let disposed = false;
159212
try {
160213
return cb({
@@ -179,20 +232,13 @@ export class Entry {
179232
mkdirSync(dirname(join(this.path, name)), { recursive: true });
180233
writeFileSync(join(this.path, name), content);
181234
},
182-
touch: () => {
235+
markComplete: () => {
183236
if (disposed) {
184237
throw new Error(
185238
`Cannot touch ${this.path} once the lock block was returned!`,
186239
);
187240
}
188-
if (this.pathExists) {
189-
if (existsSync(this.#markerFile)) {
190-
const now = new Date();
191-
utimesSync(this.#markerFile, now, now);
192-
} else {
193-
writeFileSync(this.#markerFile, '');
194-
}
195-
}
241+
this.#touchMarkerFile();
196242
},
197243
});
198244
} finally {
@@ -201,6 +247,23 @@ export class Entry {
201247
}
202248
}
203249

250+
/**
251+
* Update the timestamp on the marker file
252+
*/
253+
#touchMarkerFile() {
254+
if (this.pathExists) {
255+
try {
256+
const now = new Date();
257+
utimesSync(this.#markerFile, now, now);
258+
} catch (e: any) {
259+
if (e.code !== 'ENOENT') {
260+
throw e;
261+
}
262+
writeFileSync(this.#markerFile, '');
263+
}
264+
}
265+
}
266+
204267
public read(file: string): Buffer | undefined {
205268
try {
206269
return readFileSync(join(this.path, file));
@@ -217,7 +280,12 @@ export interface LockedEntry {
217280
delete(): void;
218281
write(name: string, data: Buffer): void;
219282

220-
touch(): void;
283+
/**
284+
* Mark the entry has having been completed
285+
*
286+
* The modification time of this file is used for cleanup.
287+
*/
288+
markComplete(): void;
221289
}
222290

223291
function* directoriesUnder(
@@ -242,3 +310,45 @@ function* directoriesUnder(
242310
}
243311
}
244312
}
313+
314+
/**
315+
* We must use 'lockSync', but that doesn't support waiting (because waiting is only supported for async APIs)
316+
* so we have to build our own looping locker with waits
317+
*/
318+
function lockSyncWithWait(path: string, options: Options) {
319+
let retries = options.retries ?? 0;
320+
let sleep = 100;
321+
322+
// eslint-disable-next-line no-constant-condition
323+
while (true) {
324+
try {
325+
lockSync(path, {
326+
retries: 0,
327+
stale: options.stale,
328+
});
329+
return;
330+
} catch (e: any) {
331+
if (retries === 0) {
332+
throw e;
333+
}
334+
retries--;
335+
336+
if (e.code === 'EEXIST') {
337+
// Most common case, needs longest sleep. Randomize the herd.
338+
sleepSync(Math.floor(Math.random() * sleep));
339+
sleep *= 1.5;
340+
} else {
341+
sleepSync(5);
342+
}
343+
}
344+
}
345+
}
346+
347+
/**
348+
* Abuse Atomics.wait() to come up with a sync sleep
349+
*
350+
* We must use a sync sleep because all of jsii is sync.
351+
*/
352+
function sleepSync(ms: number) {
353+
Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, ms);
354+
}

0 commit comments

Comments
 (0)