GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — fix(zone.js): guard against null handle when detecting refreshable ti… · angular/angular@36c2197

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • packages/zone.js
    • lib/common
      • timers.ts
    • test/common
      • setTimeout.spec.ts
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎packages/zone.js/lib/common/timers.ts‎

Copy file name to clipboardExpand all lines: packages/zone.js/lib/common/timers.ts
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ export function patchTimer(window: any, setName: string, cancelName: string, nam
4949
} else {
5050
data.handle = handleOrId;
5151
// On Node.js a timeout and interval can be restarted over and over again by using the `.refresh` method.
52-
data.isRefreshable = isFunction(handleOrId.refresh);
52+
data.isRefreshable = isFunction(handleOrId?.refresh);
5353
}
5454

5555
return task;
Collapse file

‎packages/zone.js/test/common/setTimeout.spec.ts‎

Copy file name to clipboardExpand all lines: packages/zone.js/test/common/setTimeout.spec.ts
+13Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,4 +151,17 @@ describe('setTimeout', function () {
151151
clearTimeout(null as any);
152152
clearTimeout(<any>{});
153153
});
154+
155+
it('should not throw when the native timer returns null', function () {
156+
// A wrapper that blocks a timer (e.g. a browser extension or automation
157+
// harness) can return null instead of a handle, see issue #70044.
158+
const fakeGlobal = {
159+
setTimeout: function () {
160+
return null;
161+
},
162+
clearTimeout: function () {},
163+
};
164+
patchTimer(fakeGlobal, 'set', 'clear', 'Timeout');
165+
expect(() => (fakeGlobal as any).setTimeout(() => {}, 0)).not.toThrow();
166+
});
154167
});

0 commit comments

Comments
0 (0)
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.