Compare commits
1 Commits
813f81af9a
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| 959e635bb5 |
11
server.ts
11
server.ts
@@ -98,6 +98,7 @@ mcp.setRequestHandler(CallToolRequestSchema, async req => {
|
|||||||
let ws: WebSocket | null = null
|
let ws: WebSocket | null = null
|
||||||
let backoff = 1000
|
let backoff = 1000
|
||||||
const outbox: unknown[] = []
|
const outbox: unknown[] = []
|
||||||
|
let firstInboundDelivered = false
|
||||||
|
|
||||||
function bridgeSend(frame: unknown): void {
|
function bridgeSend(frame: unknown): void {
|
||||||
if (ws && ws.readyState === WebSocket.OPEN) {
|
if (ws && ws.readyState === WebSocket.OPEN) {
|
||||||
@@ -147,6 +148,16 @@ async function handleBridge(frame: any): Promise<void> {
|
|||||||
log(`hello_ack received`)
|
log(`hello_ack received`)
|
||||||
return
|
return
|
||||||
case 'inbound':
|
case 'inbound':
|
||||||
|
// Race guard: Claude Code's internal "Channel notifications registered"
|
||||||
|
// log line appears ~25ms AFTER we send hello_ack — if we push the
|
||||||
|
// notification before then, claude silently drops it. Buffer the
|
||||||
|
// first inbound briefly to dodge this. Subsequent inbounds don't
|
||||||
|
// need the wait (channel is registered for the lifetime of the
|
||||||
|
// session).
|
||||||
|
if (!firstInboundDelivered) {
|
||||||
|
await new Promise(r => setTimeout(r, 800))
|
||||||
|
firstInboundDelivered = true
|
||||||
|
}
|
||||||
await mcp.notification({
|
await mcp.notification({
|
||||||
method: 'notifications/claude/channel',
|
method: 'notifications/claude/channel',
|
||||||
params: {
|
params: {
|
||||||
|
|||||||
Reference in New Issue
Block a user