Secure token request helper swallows API errors and hides auth/cookie failures

Open Beginner friendly
#1,141 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
65/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
typescript

Research direction

Start at packages/auth/src/utils/tokenRequestHandler.ts:25-26 and inspect the catch block and its callers. Reproduce a failed /auth-token request in secure auth mode, then verify that request failures reject instead of resolving to undefined and that callers can distinguish failure from a missing token.

Written by the indexing model from the issue text.

Description

bug

Summary

tokenRequestHandler logs errors but does not rethrow them, causing failed secure token requests to silently resolve as undefined.

Affected Code

  • packages/auth/src/utils/tokenRequestHandler.ts:25
  • packages/auth/src/utils/tokenRequestHandler.ts:26

Problem

In the catch block, errors are only logged:

  • no rethrow
  • no explicit failure result

This makes callers treat real request failures as missing token/null-like outcomes.

Impact

  • Silent auth/cookie failures
  • Hard-to-debug secure login behavior
  • Error handling paths are bypassed because promise rejection never occurs

Reproduction

  1. Use secure auth mode.
  2. Cause /auth-token request to fail (network failure / non-2xx).
  3. Observe tokenRequestHandler returns undefined instead of rejecting.
  4. Caller falls back as if no token was present.

Expected

Request failure should reject so callers can handle true error conditions.

Actual

Failure is swallowed and converted into implicit undefined.

Proposed Fix

Rethrow after logging in tokenRequestHandler (or return a typed error result), so callers can reliably distinguish failure from missing token cases.

Dominant language
JavaScript
Stars
165
Forks
381
Avg merge
1d 2h
Merged PRs (30d)
1

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from RocketChat/EmbeddedChat

All issues in RocketChat/EmbeddedChat

Similar issues

More JavaScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.