Skip to content

Proxy graceful error handling misses prefixed route paths (e.g. meta-tr) #639

@felixgabler

Description

@felixgabler

Description

The proxy handler's graceful error handling (return 204 on upstream failure) doesn't match prefixed analytics routes like /_proxy/meta-tr.

proxy-handler.ts, catch block:

if (path.includes("/collect") || path.includes("/tr") || path.includes("/events")) {
  event.node.res.statusCode = 204;
  return "";
}

The Meta Pixel route is /_proxy/meta-tr/**https://www.facebook.com/tr/**. When the upstream is unreachable, the path /_proxy/meta-tr does not contain the substring /tr (it's -tr), so the check fails and the handler throws a 502 instead of silently returning 204.

Impact

~6K server-side Sentry errors/day from POST /_proxy/meta-tr with "Failed to reach upstream".

Suggestion

Match against the resolved upstream target URL (which does contain /tr) instead of the incoming proxy path. Or match all /_proxy/** routes in the catch block since they're all analytics endpoints.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions