-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
[NextJS] Latest browser updates appear to have changed behavior of snapshots #1936
Comments
I'm not familiar with the NextJS internals but it may be using React's Fast Refresh. Does #1891 resolve your issue? That isn't part of a public release yet but should be in the |
Experiencing the same. The
It's not an issue on Chrome @drarmstr I tried to debug and compare with the working Chrome version and the difference seems to be in the |
Digging down the rabbit hole, I found the culprit for Chrome. Setting the timeout to 1 in the However, the issue still persists in Firefox. I tested a few older version including v86 and the issue persists. Has this always been an issue? I'm running Firefox, Next.js I tried tracing
This is where it starts to differ. Chrome:
I'm at a lost at how the count works once the new snapshot become part of the equation. The number does add up if there's 2 different Snapshot instance. In Firefox, continuing from the first common part:
I hope that somewhat helps. I'm not too sure how the Snapshot cloning works. At the end of the day, setting the timeout to a higher number (eg: 10) seems to fix it for Firefox. So I'll be doing that as a fix for now since I've spent a day on this 😂 |
Ah, thanks for diving into this! There are a few other places with setTimeout() such as in |
Summary: Resolves facebookexperimental#1936 It appears that some browsers changed behavior for `setTimeout(..., 0);`. The timeout previously had a minimum value of 1 but now has new behavior for 0. This caused code ordering changes which broke snapshot auto release for some browsers, though likely only for dev mode when React Fast Refresh was being used (tested by Vija02 with Chrome 104.0.5112.79 and Firefox 103.0.1 using NextJS dev mode). Update the timeouts to workaround this issue. Differential Revision: D38591482 fbshipit-source-id: 278f101b4734d039409abc963bc0d1df9277a748
…tal#1943) Summary: Pull Request resolved: facebookexperimental#1943 Resolves facebookexperimental#1936 It appears that some browsers changed behavior for `setTimeout(..., 0);`. The timeout previously had a minimum value of 1 but now has new behavior for 0. This caused code ordering changes which broke snapshot auto release for some browsers, though likely only for dev mode when React Fast Refresh was being used (tested by Vija02 with Chrome 104.0.5112.79 and Firefox 103.0.1 using NextJS dev mode). Update the timeouts to workaround this issue. Differential Revision: https://www.internalfb.com/diff/D38591482?entry_point=27 fbshipit-source-id: 584741ec055bd9f1d34adf0fe721191d78e49d9b
0.7.5 released |
I can also confirm that 0.7.5 fixed the issue for me in Firefox. Thanks! |
I still have this bug on Firefox (105.0b9). |
Yes, I had to pnpm patch |
Starting last night (8/4/2022), Our DebugObserver component started throwing on
useRecoilSnapshot
with the error that the snapshot has already been released.This reproduces on new versions of browsers only...installing older versions (and testing before they auto-update), we do not get this exception with the exact same code. This is the only place in our code we're using snapshots directly.
I tried reverting to older builds of recoil, running the code on other machines, different browsers, and my coworkers see the same behavior this morning.
Our application is build with NextJs...here are our dependencies:
I'd be surprised if we're the only ones experiencing odd new behavior today.
EDIT: I should add that this only repros when running
next dev
but works when runningnext start
. I'm not sure if this implies a problem with nextjs with the new browser update or a problem with Recoil, or something that surfaces only when using Recoil in NextJs.The text was updated successfully, but these errors were encountered: