Skip to content

fix(BaseTransport) Fix handling of AbortSignal availability detection in selected transport #1582

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions packages/sdk-rtl/src/baseTransport.ts
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ export abstract class BaseTransport implements ITransport {
let signaller;
if (AbortSignal.timeout) {
const ms = sdkTimeout(options) * 1000;
let signaller = AbortSignal.timeout(ms);
signaller = AbortSignal.timeout(ms);
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed double let declaration, since it's block scoped, and would cause a new blocked scoped variable, which shadowed the top level signaller but the blocked scoped value was never included in props, since it's destroyed as soon as this block is executed.

if ('signal' in options && options.signal) {
// AbortSignal.any may not be available, tolerate its absence
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
Expand All @@ -189,11 +189,11 @@ export abstract class BaseTransport implements ITransport {
);
console.debug({ AbortSignal });
}
} else {
console.debug(
'AbortSignal.timeout is not defined. Timeout will use default behavior'
);
}
} else {
console.debug(
'AbortSignal.timeout is not defined. Timeout will use default behavior'
);
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This log was being generated even if AbortSignal.timeout was available in the runtime, since it was attached to the wrong condition (options.signal)

}

let props: IRequestProps = {
Expand Down