Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

null is not an object (evaluating 'b.parentNode') in production #70048

Unanswered
Fonger asked this question in App Router
Discussion options

I don't know how to reproduce but it seems it only happen in Safari.

My Sentry keeps receiving reports from users like this

app:///xxxx(path-to-the-page) in $RS at line 1:119385

with error message:

null is not an object (evaluating 'b.parentNode')

I search the HTML document reporting the error, I see

<script>$RS=function(a,b){a=document.getElementById(a);b=document.getElementById(b);for(a.parentNode.removeChild(a);a.firstChild;)b.parentNode.insertBefore(a.firstChild,b);b.parentNode.removeChild(b)};

This indicates that param b, which is document.getElementById(b) is somehow null.

This code seems to be replated to streaming rendering and this is how the server-sent data push to the client suspense <template id="xxx"/> slot.

Is it possible? how come $RS() calling tries to to insert a non-existing template slot id?

I can't produce it but sentry logs indicate the following environments. All of them are from Sarari.

Note these data with 3% sample rate and this indicating that the actual affected users are 33 times larger than this. And it's within 24hr.

image

You must be logged in to vote

Replies: 3 comments 9 replies

Comment options

I am having same issue on Nextjs 14.2

You must be logged in to vote
0 replies
Comment options

This seems to come from React itself... 🤔 Could it be a browser extension, or perhaps people who tell their browser to translate the site?

  • var completeSegmentScript1Full = stringToPrecomputedChunk(
    '$RS=function(a,b){a=document.getElementById(a);b=document.getElementById(b);for(a.parentNode.removeChild(a);a.firstChild;)b.parentNode.insertBefore(a.firstChild,b);b.parentNode.removeChild(b)};$RS("'
    ),
    completeSegmentScript1Partial = stringToPrecomputedChunk('$RS("'),
    completeSegmentScript2 = stringToPrecomputedChunk('","'),
    completeSegmentScriptEnd = stringToPrecomputedChunk('")\x3c/script>');
You must be logged in to vote
1 reply
Comment options

@Fonger @Behnoudmst I went over to the React repo, and found this, facebook/react#25710

Apparently, wrapping the entire HTML document with a Suspense boundary, could cause this issue: facebook/react#25710 (comment)

Comment options

facing same issue with the Next 15.3.1

You must be logged in to vote
8 replies
Comment options

Not really, sorry @icyJoseph. And in my case is not just Safari.
Could it be related to having a client component for the loading.tsx file?
As the loading animation on our case depends on the accessed path, and the loading.tsx doesn't get dynamic routes values, I needed to make it a client component.

Comment options

Is there a publicly available site? Could try to debug there if so. Worth trying latest 15.5.6, on the way there React got some updates, which might have fixed this.

Comment options

Created a PR for my app which has a PR preview upgrading to Next.js 15.5.6 and still happening. Managed to move things around to rely on server side loading.tsx file and still happening. The app continues to work well, but Sentry is going crazy with this error.

Maybe there is a way the line mentioned above and the other flavors (bun, etc) like the following

'$RS=function(a,b){a=document.getElementById(a);b=document.getElementById(b);for(a.parentNode.removeChild(a);a.firstChild;)b.parentNode.insertBefore(a.firstChild,b);b.parentNode.removeChild(b)};$RS("'
can be patched to not throw an error when there is no elements in a or b which results in a null reference. Seems like an oversight to me, even if it is not expected to have an empty element, it's safer to assume it could not have an element and not apply the change instead of erroring out. I could create a PR to patch those files but doesn't seem right; those are part of the compiled version of next.js under the react-dom dependency.

Found this other instance of the same issue facebook/react#25710 by @tannerlinsley.

cc: @timneutkens who has helped me with next.js issues in the past.

Comment options

@leog That issue from the React repository, was also mentioned here, #70048 (reply in thread) and it looks like it comes from placing a Suspense outside the body?

It's specifically node outside that's not supported

Comment options

@icyJoseph sorry for the delay, and it's not my case, don't have any Suspense outside the body

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

AltStyle によって変換されたページ (->オリジナル) /