fix(core): make instanceof on SDK error classes work across bundled copies (#2384)
This commit is contained in:
parent
e6cc5dc633
commit
ce2f65db0e
1 changed files with 1020 additions and 26 deletions
|
|
@ -113,11 +113,12 @@ let challenged = false;
|
|||
try {
|
||||
await client.connect(firstTransport);
|
||||
} catch (error) {
|
||||
// Under `--legacy` the transport surfaces `UnauthorizedError` directly;
|
||||
// under `mode: 'auto'` the version-negotiation probe is what got 401'd
|
||||
// and wraps it in an EraNegotiationFailed `SdkError` whose `data.cause`
|
||||
// is the original `UnauthorizedError`. Either way the auth driver has
|
||||
// already run by the time we land here — DCR done, auth URL captured.
|
||||
// Both `--legacy` and `mode: 'auto'` surface the original
|
||||
// `UnauthorizedError` directly (the negotiation probe propagates it
|
||||
// unchanged; older releases wrapped it as the `data.cause` of an
|
||||
// EraNegotiationFailed `SdkError`, which the unwrap below still
|
||||
// tolerates). Either way the auth driver has already run by the time we
|
||||
// land here — DCR done, auth URL captured.
|
||||
const root = error instanceof UnauthorizedError ? error : (error as { data?: { cause?: unknown } }).data?.cause;
|
||||
if (!(root instanceof UnauthorizedError)) throw error;
|
||||
challenged = true;
|
||||
|
|
|
|||
Loading…
Reference in a new issue