hoppscotch/hoppscotch · error · Error

Team Request Added Error: ${JSON.stringify(result.left)}

Error message

Team Request Added Error: ${JSON.stringify(result.left)}

What it means

Thrown inside the TeamRequestAdded GraphQL subscription callback in registerSubscriptions() when the subscription delivers a Left result. This callback handles real-time 'request added' events, parsing the request JSON via translateToNewRequest. The throw-in-next pattern risks crashing the chain, and a throw before JSON.parse would mask the subscription error as a parse error.

Source

Thrown at packages/hoppscotch-common/src/services/team-collection.service.ts:778

      if (E.isLeft(result))
        throw new Error(
          `Team Collection Removed Error: ${JSON.stringify(result.left)}`
        )

      this.removeCollection(result.right.teamCollectionRemoved)
    })

    const [teamReqAdded$, teamReqAddedSub] = runGQLSubscription({
      query: TeamRequestAddedDocument,
      variables: {
        teamID: this.teamID,
      },
    })

    this.teamRequestAddedSub = teamReqAddedSub
    this.teamRequestAdded$ = teamReqAdded$.subscribe((result: any) => {
      if (E.isLeft(result))
        throw new Error(
          `Team Request Added Error: ${JSON.stringify(result.left)}`
        )

      this.addRequest({
        id: result.right.teamRequestAdded.id,
        collectionID: result.right.teamRequestAdded.collectionID,
        request: translateToNewRequest(
          JSON.parse(result.right.teamRequestAdded.request)
        ),
        title: result.right.teamRequestAdded.title,
      })
    })

    const [teamReqUpdated$, teamReqUpdatedSub] = runGQLSubscription({
      query: TeamRequestUpdatedDocument,
      variables: {
        teamID: this.teamID,
      },

View on GitHub (pinned to 1acb8a3a75)

Solutions

  1. Replace the throw-in-next with a subscribe error callback.
  2. Wrap JSON.parse and translateToNewRequest in a try-catch to handle malformed request payloads separately.
  3. Re-register subscriptions on transient errors.
  4. Log result.left for diagnosis.

Example fix

// before
this.teamRequestAdded$ = teamReqAdded$.subscribe((result: any) => {
  if (E.isLeft(result))
    throw new Error(`Team Request Added Error: ${JSON.stringify(result.left)}`)
  this.addRequest({ ..., request: translateToNewRequest(JSON.parse(result.right.teamRequestAdded.request)), ... })
})

// after
this.teamRequestAdded$ = teamReqAdded$.subscribe({
  next: (result: any) => {
    if (E.isLeft(result)) {
      console.error('TeamRequestAdded error:', result.left)
      return
    }
    try {
      this.addRequest({ ..., request: translateToNewRequest(JSON.parse(result.right.teamRequestAdded.request)), ... })
    } catch (e) {
      console.error('Failed to parse incoming team request:', e)
    }
  },
  error: (err) => { console.error('TeamRequestAdded stream error:', err) },
})
Defensive patterns

Strategy: try-catch

Try / catch

this.teamRequestAdded$ = teamReqAdded$.subscribe({
  next: (result: any) => {
    if (E.isLeft(result)) {
      console.error('TeamRequestAdded error:', result.left)
      return
    }
    try {
      this.addRequest({
        ...,
        request: translateToNewRequest(JSON.parse(result.right.teamRequestAdded.request)),
        ...,
      })
    } catch (e) { console.error('Failed to parse incoming team request:', e) }
  },
  error: (err) => { console.error('TeamRequestAdded stream error:', err) },
})

Prevention

When it happens

Trigger: The TeamRequestAdded subscription emits an error result — WebSocket drop, backend GraphQL error, auth expiry, or invalid teamID. A separate risk: if result.right.teamRequestAdded.request is malformed JSON, JSON.parse would throw a SyntaxError (not this error), but the Left-check throw fires first when the result is an error.

Common situations: Network interruption; auth token expired; backend restart; team access changed; concurrent add event with unexpected payload shape.

Related errors


AI-assisted analysis of hoppscotch/hoppscotch@1acb8a3a75 (2026-08-12). Data as JSON: /api/errors/7c560184d9038f9e. Report an issue: GitHub.