Skip to content
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

fix(runtime): pages are not editable when running in dev w/ NextJS 14.2 #728

Merged
merged 1 commit into from Apr 26, 2024

Conversation

agurtovoy
Copy link
Contributor

@agurtovoy agurtovoy commented Apr 22, 2024

Decouple MessageChannel creation from the middleware creation to make store initalization compatible with React's strict mode.

Next.js has React's strict mode enabled by default in dev; when running w/ Next.js 14.2 and App Router in dev, creation of the channel in the middleware was resulting in a secondary "ghost" store instance that was handling some of the dispatch methods, leading to a de-synchronized runtime state.

Copy link

linear bot commented Apr 22, 2024

Copy link

changeset-bot bot commented Apr 22, 2024

🦋 Changeset detected

Latest commit: 9fa9492

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@makeswift/runtime Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link

vercel bot commented Apr 22, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
makeswift-examples-bigcommerce ✅ Ready (Inspect) Visit Preview 💬 Add feedback Apr 26, 2024 4:37pm
makeswift-examples-bigcommerce-catalyst ❌ Failed (Inspect) Apr 26, 2024 4:37pm
makeswift-nextjs-app-router ✅ Ready (Inspect) Visit Preview 💬 Add feedback Apr 26, 2024 4:37pm
makeswift-nextjs-pages-router ✅ Ready (Inspect) Visit Preview 💬 Add feedback Apr 26, 2024 4:37pm
3 Ignored Deployments
Name Status Preview Comments Updated (UTC)
makeswift-examples-basic-typescript ⬜️ Ignored (Inspect) Visit Preview Apr 26, 2024 4:37pm
makeswift-examples-shopify ⬜️ Ignored (Inspect) Visit Preview Apr 26, 2024 4:37pm
makeswift-examples-thirdweb ⬜️ Ignored (Inspect) Visit Preview Apr 26, 2024 4:37pm

Copy link
Member

@migueloller migueloller left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@agurtovoy, we use changesets to manage releases. It takes care of generating change logs as well as updating package versions, GitHub releases, git tags, canary releases, etc.

packages/runtime/src/state/react-builder-preview.ts Outdated Show resolved Hide resolved
migueloller
migueloller previously approved these changes Apr 23, 2024
Copy link
Member

@migueloller migueloller left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems reasonable! Again, nice find. Imm wondering if this will also address a memory leak we’ve been having due to not handling message channels from function serialization.

Instead of actions we could also perform the side effects in a thunk. I realized as I was reading this that that would be more friendly to Redux since doing a side effect on an action is against Redux’s assumptions. And this applies regardless of whether we do a mixin or not (I incorrectly couple these two when we discussed this earlier). The crux here is wether we perform the side effect and cleanup as a response to a Redux action or within the thunk itself. If done in an action, certain things, like time travel in Redux DevTools won’t work as expected.

Don’t forget to add a changeset!

migueloller
migueloller previously approved these changes Apr 26, 2024
Copy link
Member

@migueloller migueloller left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks great! 👍🏻

Left some comments but they're either questions or nits. Feel free to ship without addressing them.

Thanks @agurtovoy 🙏🏻

.changeset/chilly-peaches-wonder.md Outdated Show resolved Hide resolved
packages/runtime/src/state/react-builder-preview.ts Outdated Show resolved Hide resolved
packages/runtime/src/state/react-builder-preview.ts Outdated Show resolved Hide resolved
Decouple `MessageChannel` creation from the middleware creation to make store initalization compatible with React strict mode. Creation of the channel in the middleware was resulting in a "ghost" store instance that was handling some of the dispatch methods.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants