Skip to content

Commit 3cbdb0a

Browse files
committed
fix: prevent package cleanup race
1 parent 700d85e commit 3cbdb0a

2 files changed

Lines changed: 10 additions & 2 deletions

File tree

scripts/check-package.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ const consumerDir = path.join(workDir, 'consumer');
5252
function run(command: string, args: string[], cwd: string): string {
5353
return execFileSync(command, args, {
5454
cwd,
55+
env: { ...process.env, AGENT_DEVICE_NO_UPDATE_NOTIFIER: '1' },
5556
encoding: 'utf8',
5657
maxBuffer: 64 * 1024 * 1024,
5758
stdio: ['ignore', 'pipe', 'inherit'],
@@ -148,8 +149,10 @@ if (failures.length > 0) {
148149
* `devices` and `doctor --remote` are the cheapest commands that load the daemon bundle and the
149150
* remote-config graph — the lazily imported halves of the CLI that no `--version` or `help` run
150151
* reaches, and where the 0.20.4 unresolved import actually surfaced. Every command is device-free and
151-
* offline. `--state-dir` keeps the daemon they start out of the developer's `~/.agent-device`, and
152-
* `daemon stop` leaves nothing running behind the check.
152+
* offline. The subprocess environment disables the detached update notifier so the non-JSON
153+
* `daemon stop` probe cannot recreate files while the temporary consumer is being removed.
154+
* `--state-dir` keeps the daemon they start out of the developer's `~/.agent-device`, and `daemon
155+
* stop` leaves nothing running behind the check.
153156
*/
154157
function smokeTestBin(installedRoot: string, manifest: PackedManifest): void {
155158
const binPath = path.join(installedRoot, manifest.bin['agent-device']!);

src/__tests__/npm-package-scripts.test.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,11 @@ test('the package gate runs the closure audit and both runtime probes', () => {
101101
}
102102
});
103103

104+
test('the package gate disables the detached update notifier for its smoke probes', () => {
105+
const gate = fs.readFileSync(path.join(repoRoot, 'scripts', 'check-package.ts'), 'utf8');
106+
assert.match(gate, /env: \{ \.\.\.process\.env, AGENT_DEVICE_NO_UPDATE_NOTIFIER: '1' \}/);
107+
});
108+
104109
// The gate reads the packed tarball, so `prepack` is the last point where a broken package can still
105110
// be stopped. Publishing runs it; nothing else guarantees the tarball is ever verified.
106111
test('publishing cannot skip the package gate', () => {

0 commit comments

Comments
 (0)