From a2577922d8ce5e31256dcf396ecc688c484a8067 Mon Sep 17 00:00:00 2001 From: Massimiliano Angelino Date: Fri, 6 Dec 2024 18:52:10 +0100 Subject: [PATCH] fix: binding the methods to the context (#1466) * fix: binding the methods to the context * fix(1465):changeset * fix: replace bind with arrow function * fix: types * loosen forwarding types --------- Co-authored-by: George Fu --- .changeset/large-squids-rush.md | 5 +++++ packages/node-http-handler/src/timing.ts | 5 +++-- 2 files changed, 8 insertions(+), 2 deletions(-) create mode 100644 .changeset/large-squids-rush.md diff --git a/.changeset/large-squids-rush.md b/.changeset/large-squids-rush.md new file mode 100644 index 00000000000..110d2893cb0 --- /dev/null +++ b/.changeset/large-squids-rush.md @@ -0,0 +1,5 @@ +--- +"@smithy/node-http-handler": patch +--- + +Added context binding to the setTimeout and clearTimeout functions diff --git a/packages/node-http-handler/src/timing.ts b/packages/node-http-handler/src/timing.ts index f78f530bc45..71d8926a4d4 100644 --- a/packages/node-http-handler/src/timing.ts +++ b/packages/node-http-handler/src/timing.ts @@ -3,6 +3,7 @@ * For test spies. */ export const timing = { - setTimeout: setTimeout, - clearTimeout: clearTimeout, + setTimeout: (cb: (...ignored: any[]) => void | unknown, ms?: number) => setTimeout(cb, ms), + clearTimeout: (timeoutId: string | number | undefined | unknown) => + clearTimeout(timeoutId as Parameters[0]), };