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 infinite loop in Suspense error handling on the server #1649

Merged
merged 1 commit into from
Mar 26, 2023

Conversation

thetarnav
Copy link
Contributor

Summary

Fixes #1648

Suspense was attaching it's onError not to the o new owner it created, but to the current Owner, which ends up being the parent of o. So when it tries to pass the error to the parent with runWithOwner, it's actually passing it to itself creating an infinite loop.

How did you test this change?

I see there are no server tests for solid-js at the moment. But patching solid-js locally has solved this issue for me.
I'm not sure if I should maybe try adding one using // @jest-environment node comment to force node env with jest?
Maybe after #1609 gets merged this could be improved.

@changeset-bot
Copy link

changeset-bot bot commented Mar 25, 2023

⚠️ No Changeset found

Latest commit: 61aaf7c

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

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

@coveralls
Copy link

Pull Request Test Coverage Report for Build 4520261937

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage remained the same at 88.27%

Totals Coverage Status
Change from base Build 4441656855: 0.0%
Covered Lines: 1305
Relevant Lines: 1402

💛 - Coveralls

@@ -552,7 +552,6 @@ export function SuspenseList(props: {

export function Suspense(props: { fallback?: string; children: string }) {
let done: undefined | ((html?: string, error?: any) => boolean);
let clean: any;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

clean wasn't being used anywhere anymore. maybe that's a mistake? not sure what it did

@@ -569,8 +568,8 @@ export function Suspense(props: { fallback?: string; children: string }) {
});
function runSuspense() {
setHydrateContext({ ...ctx, count: 0 });
o && cleanNode(o);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

o is always present. before 1.6.13 clean was checked here

Copy link
Member

Choose a reason for hiding this comment

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

Are we sure we can just remove it? I hoisted it up for sure and that caused the issue, but it was always there. I guess I can retest the original React Query scenario.

Copy link
Contributor Author

@thetarnav thetarnav Mar 25, 2023

Choose a reason for hiding this comment

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

pre 1.6.13 the current Owner would get assigned as o so it could be null, now we are always creating a new owner so the condition is pointless.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Also, github is showing the preview a bit weirdly. I didn't remove cleanNode(o), just o &&

Copy link
Member

Choose a reason for hiding this comment

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

Oh I get it. Yeah I was looking at the wrong part. I guess the trickiest part is I change this mechanism completely in 1.7. It's going to be a bit interesting to figure out how to merge this back into next. It looks like I need to do another 1.6 release given the stuff I've broken though so I will go with this for now.

@ryansolid ryansolid merged commit 1d4d532 into solidjs:main Mar 26, 2023
@thetarnav thetarnav deleted the fix-infinite-loop branch March 26, 2023 07:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Maximum call stack size exceeded in Suspense error handling on the server
3 participants