fix: handle Bun daemon argv duplication (#112) (thanks @dedene)

This commit is contained in:
Peter Steinberger 2026-03-28 20:58:47 +00:00
parent 20bd05bfda
commit 02058c37fa
No known key found for this signature in database
2 changed files with 51 additions and 0 deletions

View File

@ -3,6 +3,7 @@
## [Unreleased]
### CLI
- Skip Bun compiled `/$bunfs/...` argv entries when detached daemon restarts spawn child processes, so compiled binaries do not duplicate the virtual entry path and lose the `daemon` command. (PR #112, thanks @dedene)
- Keep `mcporter call --output json` parseable by emitting valid JSON even when the command falls back to raw output. (PR #128, thanks @armanddp)
- Ignore static `Authorization` headers once OAuth is active so imported editor configs cannot override fresh OAuth tokens. (PR #123, thanks @ahonn)
- Preserve full JSON/error payloads when `data` is just one field instead of collapsing the response to `data` alone. (PR #106, thanks @AielloChan)

View File

@ -0,0 +1,50 @@
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
const spawnMock = vi.fn(() => ({ unref: vi.fn() }));
vi.mock('node:child_process', () => ({
spawn: spawnMock,
}));
const originalArgv = [...process.argv];
const originalExecArgv = [...process.execArgv];
describe('launchDaemonDetached', () => {
beforeEach(() => {
spawnMock.mockClear();
process.argv = ['/tmp/mcporter', '/$bunfs/root/mcporter.js'];
process.execArgv = ['--smol'];
});
afterEach(() => {
process.argv = [...originalArgv];
process.execArgv = [...originalExecArgv];
});
it('omits Bun virtual entry paths from detached child args', async () => {
const { launchDaemonDetached } = await import('../src/daemon/launch.js');
launchDaemonDetached({
configPath: '/tmp/mcporter.json',
configExplicit: true,
rootDir: '/repo',
socketPath: '/tmp/mcporter.sock',
metadataPath: '/tmp/mcporter.meta.json',
extraArgs: ['--log'],
});
expect(spawnMock).toHaveBeenCalledWith(
process.execPath,
['--smol', '--config', '/tmp/mcporter.json', '--root', '/repo', 'daemon', 'start', '--foreground', '--log'],
expect.objectContaining({
detached: true,
stdio: 'ignore',
env: expect.objectContaining({
MCPORTER_DAEMON_CHILD: '1',
MCPORTER_DAEMON_SOCKET: '/tmp/mcporter.sock',
MCPORTER_DAEMON_METADATA: '/tmp/mcporter.meta.json',
}),
})
);
});
});