codesandbox / codesandbox/codesandbox-client

Script tag injection makes Remix hydration fail

Open
#7,959 0 comments 7 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
13.6k
Forks
2.4k
Avg merge
6d 19h
Merged PRs (30d)
2

Description

🐛 bug report

Preflight Checklist

  • I have read the Contributing Guidelines for this project.
  • I agree to follow the Code of Conduct that this project
    adheres to.
  • I have searched the issue tracker for an issue that matches the one I want
    to file, without success.

Description of the problem

I suspect the injection of a <script> with preview-protocol.js as its src causes an error with hydration on Remix applications.
It even does so on the official Remix CodeSandbox.

How has this issue affected you? What are you trying to accomplish?

When using react-dom <= 18.1.0, the hydration error makes the whole page go blank.
On react-dom = 18.2.0, it does not make it blank but still outputs the error in the console. This can be a problem as it can obscure actual hydration problems caused by the source code, and perhaps other issues I'm not aware of.

To Reproduce
  • Simply set up a CodeSandbox of an app using Remix, or use the official template
  • Open Console in Devtools
  • Errors related to hydration are logged
Link to sandbox:

Official Remix template

Remix template with react-dom downgraded, in this one it makes the page go blank

Your Environment
Software Name/Version
Сodesandbox V2
Browser Chromium 115.0.5790.170 (arm64)
Operating System ARM MacOS 13.5

CodeSandbox version :
Version: V2
Environment: production
Sandbox: 5wfvj7
Pitcher: 0.306.0
Manager: 1.23.2
Cluster: fc-eu-0

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the preview-protocol.js script injection described in the report and reproduce the issue using the linked official Remix CodeSandbox. Compare hydration behavior with react-dom 18.1.0 and 18.2.0; done means the Remix page renders without a hydration error or blank page caused by the injected script.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, react
Domain
frontend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.