-
Notifications
You must be signed in to change notification settings - Fork 11.5k
Open
Labels
bugSomething isn't workingSomething isn't working
Description
Description
Ideally server.close() returns a promise that resolves once the port is resumed.
The starter code when running via tsx --watch <script> or node --watch <script> (basically anything that restarts quickly) will attempt to create an opencode server before the opencode server created by the previous invocation has fully shut down.
Code:
import { createOpencode } from '@opencode-ai/sdk';
async function go() {
const { client } = await createOpencode();
const sessionResponse = await client.session.list();
const sessions = sessionResponse.data;
console.log(sessions);
const projectsResponse = await client.project.list();
console.log(projectsResponse.data);
}
go();tsx --watch index.tsRepro steps:
- run
tsx --watch index.ts - observe the server is created successfully
- make a change and save within
index.ts, causing the script to restart quickly - observe a
error: Failed to start server. Is port 4096 in use?error
This feels like a good first issue.
OpenCode version
@opencode-ai/sdk 1.0.16
opencode --version
0.15.31
Steps to reproduce
See above
Screenshot and/or share link
No response
Operating System
Mac OS
Terminal
No response
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working