Skip to content

Missing error handling in Share API fetch calls leads to silent failures #11697

Closed

Description

@ryan-mt

Summary

The Share module's fetch calls lack proper error handling, which can cause unhandled promise rejections and silent failures.

Location

packages/opencode/src/share/share.ts:29-46, 77-82, 87-90

Issue

1. sync() function (line 29) - No error handling

return fetch(\`\${URL}/share_sync\`, {
  method: "POST",
  body: JSON.stringify({...}),
})
// Missing .catch() - network errors cause unhandled rejection

2. create() function (lines 77-82) - No HTTP status check

return fetch(\`\${URL}/share_create\`, {...})
  .then((x) => x.json())  // No check for response.ok
  .then((x) => x as { url: string; secret: string })

3. remove() function (lines 87-90) - Same issues

Impact

  • Severity: Medium
  • Share sync failures are never logged or reported
  • HTTP errors (4xx, 5xx) are treated as success
  • Network failures cause unhandled promise rejections

Suggested Fix

Add proper error handling with status checks:

export async function create(sessionID: string) {
  if (disabled) return { url: "", secret: "" }
  const response = await fetch(\`\${URL}/share_create\`, {
    method: "POST",
    body: JSON.stringify({ sessionID }),
  })
  if (!response.ok) {
    throw new Error(\`HTTP \${response.status}\`)
  }
  return await response.json() as { url: string; secret: string }
}

Activity

  1. github-actions commented on Feb 2, 2026

    @github-actions
    Contributor

    This issue is part of a broader error handling improvement initiative. While not exact duplicates, it's related to similar error handling patterns being addressed in:

    Additionally, there are existing Share session issues that may be related to error handling gaps:

    Feel free to coordinate with these related issues when implementing error handling improvements.

  2. github-actions commented on Apr 3, 2026

    @github-actions
    Contributor

    To stay organized issues are automatically closed after 90 days of no activity. If the issue is still relevant please open a new one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions