I maintain a javascript/typescript library for dealing with recurring dates, rSchedule (which this forum won’t let me link to). A user reached out to me with some usage questions. The user is (I think) also learning javascript and they’ve been practicing / testing things out using this website (which I’ve never heard of before). While using this website to demonstrate rSchedule usage for this user, it appears I’ve found a bug.
See this example project I created on this website: the last “cell” (? not sure if that’s the proper word) is equal to an empty array. You can see the same example on codesandbox where the equivalent line produces an array containing a single date (the expected result). Without delving into whether there is a bug with my library (I don’t think there is in this case), hopefully we can all agree that these two examples should produce the same result.
Figured someone would want me to report this.
Thanks!
ps: you can find a link to the rSchedule repo on the “Observable” example I created, as well as by looking at the npm modules in the codesandbox example.
It might be worth noting that the examples in your initial post are not equivalent. To create an apt comparison you have to run the code in a single cell, like you do on codesandbox.io.
The execution order of cells is not determined by their order in the notebook.
Promises and dependency injection should work. I also recommend reading
The cell has an explicit dependency on schedule, so schedule is guaranteed to run first. What happens after (or inside) is up the script (unless you return a promise). However, the last cell is not guaranteed to run last.
Please also make sure that both the sandbox and the notebook pull in the exact same scripts, from the exact same sources. The best way to verify (in my opinion) is to check the network tab in your browser’s developer tools.
And here’s a reproduction of your bug in a simple node script:
So, this is clearly not an issue with Observable. I’m not sure why the behavior is different on CodeSandbox, but Observable’s behavior is here consistent with both vanilla JavaScript and Node.
The reason this passes on CodeSandbox is that you pinned the version of rschedule to 0.11.0. If you upgrade to 0.11.1 or 0.11.2 you should see the same bug. Edit: here is a suggestion to pin the version.
You are correct! I also see that my Observable example works when the version is pinned to 0.11.0. I’ll figure out what caused this regression and why it wasn’t picked up by any tests.
Very sorry for wasting your time! It makes sense, when I think about it, that codesandbox would always pin the module version, but I didn’t realize that it did so.