1
0
Эх сурвалжийг харах

Merge commit 'd4993fc780f98c06304c47a09c018b2f48f70926' into worktree/pr3596-global-only

Yichen Jiang 1 долоо хоног өмнө
parent
commit
27ec094db3

+ 3 - 3
packages/boot/plugin-manager/src/installer.ts

@@ -284,7 +284,7 @@ export class PluginInstaller {
     const deadline = new AbortController()
     const signal = control === undefined ? deadline.signal : AbortSignal.any([deadline.signal, control.signal])
     const timer = setTimeout(() => { deadline.abort() }, config.installTimeoutMs)
-    let exitCode: number | null
+    let exitCode: number | null = null
     try {
       checkCancelled(control)
       const child = this.spawn({
@@ -313,9 +313,9 @@ export class PluginInstaller {
     } catch (error) {
       const message = messageOf(error)
       record('stderr', `${message}\n`)
-      this.options.installLog({ ...request, jobId, argv, cwd: profileDir, spec, stream: 'stderr', text: '', exitCode: null })
+      this.options.installLog({ ...request, jobId, argv, cwd: profileDir, spec, stream: 'stderr', text: '', exitCode })
       if (error instanceof PluginOperationError && error.code === 'plugins/install-cancelled') throw error
-      throw new PluginOperationError('plugins/install-failed', `${NAME}: ${message}`, { spec, exitCode: null, log: tail.join('') }, { cause: error })
+      throw new PluginOperationError('plugins/install-failed', `${NAME}: ${message}`, { spec, exitCode, log: tail.join('') }, { cause: error })
     } finally {
       clearTimeout(timer)
     }

+ 2 - 1
packages/boot/plugin-manager/tests/plugin-manager.spec.ts

@@ -692,7 +692,7 @@ describe('PluginManager', () => {
         setInterval(() => {}, 1000);
       `)
       const ready = Promise.withResolvers<number>()
-      const { ctx, manager } = await bootProfile(staged, {}, {
+      const { ctx, manager, log } = await bootProfile(staged, {}, {
         pnpmCommand: process.execPath, installTimeoutMs: 30_000, installKillGraceMs: 50,
       })
       ctx.on('plugins/install-log', (chunk) => {
@@ -704,6 +704,7 @@ describe('PluginManager', () => {
         expect(pid).toBeGreaterThan(0)
         expect(await manager.cancelInstall(requestId)).toEqual({ status: 'cancelled' })
         expect(await result).toMatchObject({ code: 'plugins/install-cancelled' })
+        expect(log.at(-1)?.exitCode).toBe(0)
         // A reparented Linux child may remain a zombie until init reaps it; it cannot execute or write.
         let status = ''
         try { status = execFileSync('ps', ['-p', String(pid), '-o', 'stat='], { encoding: 'utf8' }).trim() } catch (error) {