question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Scheduler.flush throws unclear error when actions is empty (cannot read property 'execute' of undefined)

See original GitHub issue

Bug Report

Current Behavior Calling .flush() on a scheduler (e.g. animationFrameScheduler) with no pending actions causes an unclear exception to be thrown:

TypeError: Cannot read property 'execute' of undefined
at AnimationFrameScheduler.flush (https://rxjs-pc1ga8.stackblitz.io/turbo_modules/rxjs@6.4.0/internal/scheduler/AnimationFrameScheduler.js:31:32)
at Object.eval (https://rxjs-pc1ga8.stackblitz.io/~/index.ts:12:36)
at eval (https://rxjs-pc1ga8.stackblitz.io/~/index.ts:19:4)
at eval (https://rxjs-pc1ga8.stackblitz.io/~/index.ts:20:3)
at eval (<anonymous>)
at Qt (https://c.staticblitz.com/d/webcontainer.e1e926a8972546110c3.js:15:30145)
at https://c.staticblitz.com/d/webcontainer.e1e926a8972546110c3.js:15:38799
at U (https://c.staticblitz.com/d/webcontainer.e1e926a8972546110c3.js:15:13565)
at https://c.staticblitz.com/d/webcontainer.e1e926a8972546110c3.js:15:13207
at boot (https://rxjs-pc1ga8.stackblitz.io/dev/boot:6:3)

Reproduction

import {animationFrameScheduler} from 'rxjs';
animationFrameScheduler.flush();

Expected behavior Either one of:

  • not throwing when there are no pending actions
  • throwing a clearer error (e.g. ‘Attempting to flush an empty queue’)

Environment

  • Runtime: Chrome v73
  • RxJS version: 6.4.x

Possible Solution

See expected behavior. This appears to affect all schedulers that have this do while loop without verifying that a valid action has been shift’d off of this.actions

This may be working as intended (and no change desired for performance reasons) in which case just having this issue open and google-able would provide additional documentation

Additional context/Screenshots

#2697 Appears to have been the same issue given their stacktrace: https://github.com/ReactiveX/rxjs/blob/5.4.1/src/scheduler/AsapScheduler.ts#L17

A clearer error (or no error at all) would probably have pointed them in the right direction.


Happy to submit a fix myself if the desired behavior is defined.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:9

github_iconTop GitHub Comments

1reaction
decafdenniscommented, May 6, 2019

Still working on steps to repro, but FWIW we have a significant volume of Bugsnag reports of this bug in production despite not calling flush() explicitly anywhere:

Screen Shot 2019-05-05 at 3 55 42 PM

Edit: this is with rxjs@6.5.1, and not isolated to any browser.

0reactions
cartantcommented, May 7, 2019

My concern is that the issue is not reproducible and that there are historical issues - AFAICT - in some browsers with cancelAnimationFrame not working. Without a repro, there is nothing that can be done, IMO.

Regarding testing, a polyfill is used in this project to allow the scheduler to be tested in Node. Such an approach should work fine with fake time without Sinon.

Read more comments on GitHub >

github_iconTop Results From Across the Web

TypeError: Cannot read property 'execute' of undefined
Now when you do this, it should work: client.commands.set(command.name, command);. Before, command.name was just undefined .
Read more >
cannot read properties of undefined (reading 'id') angular
The problem is that as an Input variable, the reminders object is initially undefined until angular has finished initializing the component. See this...
Read more >
How to Avoid the Infamous "Cannot read properties of ...
That error message is telling you the function is returning undefined implicitly, but its return type does not include undefined in it. Awesome!...
Read more >
Node.js v19.3.0 Documentation
Throws value if value is not undefined or null . This is useful when testing the error argument in callbacks. The stack trace...
Read more >
Chapter 2, Server Error Message Reference
Message: Table handler doesn't support NULL in given index. ... Message: Can't execute the query because you have a conflicting read lock. Error...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found