-
Notifications
You must be signed in to change notification settings - Fork 29.7k
null is not an object (evaluating 'b.parentNode') in production #70048
-
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.
Beta Was this translation helpful? Give feedback.
All reactions
Replies: 3 comments 9 replies
-
I am having same issue on Nextjs 14.2
Beta Was this translation helpful? Give feedback.
All reactions
-
This seems to come from React itself... 🤔 Could it be a browser extension, or perhaps people who tell their browser to translate the site?
next.js/packages/next/src/compiled/react-dom/cjs/react-dom-server.node.production.js
Lines 2277 to 2282 in 09aa303
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>');
Beta Was this translation helpful? Give feedback.
All reactions
-
@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)
Beta Was this translation helpful? Give feedback.
All reactions
-
facing same issue with the Next 15.3.1
Beta Was this translation helpful? Give feedback.
All reactions
-
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.
Beta Was this translation helpful? Give feedback.
All reactions
-
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.
Beta Was this translation helpful? Give feedback.
All reactions
-
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
next.js/packages/next/src/compiled/react-dom/cjs/react-dom-server.bun.production.js
Line 6523 in bc59f21
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.
Beta Was this translation helpful? Give feedback.
All reactions
-
@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
Beta Was this translation helpful? Give feedback.
All reactions
-
@icyJoseph sorry for the delay, and it's not my case, don't have any Suspense outside the body
Beta Was this translation helpful? Give feedback.