fix(e2b): close remote lifecycle gaps
This commit is contained in:
@@ -71,9 +71,10 @@ export class E2BPtyBackend implements PtyBackend {
|
||||
}
|
||||
const session = new E2BPtySession(sandbox, handle, this.config)
|
||||
created.session = session
|
||||
for (const data of pending) session.onData(data)
|
||||
try {
|
||||
await session.initialize(spec.signal)
|
||||
const initializing = session.initialize(spec.signal)
|
||||
for (const data of pending) session.onData(data)
|
||||
await initializing
|
||||
return session
|
||||
} catch (error: unknown) {
|
||||
try {
|
||||
|
||||
@@ -52,7 +52,7 @@ describe('E2BPtyBackend and plugin', () => {
|
||||
const backend = new E2BPtyBackend(ctx, config(), async (_sandbox, received) => {
|
||||
options = received
|
||||
void received.onData(Buffer.from('banner\n'))
|
||||
setTimeout(() => { void received.onData(Buffer.from('\x1b]133;D;0\x07dsh> ')) }, 0)
|
||||
void received.onData(Buffer.from('\x1b]133;D;0\x07dsh> '))
|
||||
return created
|
||||
})
|
||||
const pending = backend.spawn({
|
||||
@@ -62,7 +62,7 @@ describe('E2BPtyBackend and plugin', () => {
|
||||
await vi.advanceTimersByTimeAsync(2)
|
||||
const session = await pending
|
||||
|
||||
expect(session.motd).toBe('dsh> ')
|
||||
expect(session.motd).toBe('banner\ndsh> ')
|
||||
expect(options).toMatchObject({ rows: 24, cols: 80, cwd: '/workspace/project', timeoutMs: 0 })
|
||||
expect(options?.envs).toMatchObject({
|
||||
TERM: 'dumb', PAGER: 'cat', GIT_PAGER: 'cat', PS1: 'dsh> ',
|
||||
|
||||
Reference in New Issue
Block a user