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

Netlify deployment issue with react-plotly.js #3494

Open
alexryanterry opened this issue Feb 20, 2025 · 2 comments
Open

Netlify deployment issue with react-plotly.js #3494

alexryanterry opened this issue Feb 20, 2025 · 2 comments

Comments

@alexryanterry
Copy link

alexryanterry commented Feb 20, 2025

Which project does this relate to?

Start

Describe the bug

When I deploy a Start app with react-plotly.js / plotly.js to Netlify, the app fails with the following:

Image

The function logs from Netlify show:

Image

Or the function logs as text:

Feb 20, 12:36:25 PM: ERROR  Uncaught Exception 	{"errorType":"ReferenceError","errorMessage":"self is not defined","stack":["ReferenceError: self is not defined","    at node_modules/@plotly/d3/d3.js (/var/task/node_modules/plotly.js/dist/plotly.js:7261:15)","    at __require (/var/task/node_modules/plotly.js/dist/plotly.js:44:52)","    at src/lib/index.js (/var/task/node_modules/plotly.js/dist/plotly.js:15130:16)","    at __require (/var/task/node_modules/plotly.js/dist/plotly.js:44:52)","    at build/plotcss.js (/var/task/node_modules/plotly.js/dist/plotly.js:15990:17)","    at __require (/var/task/node_modules/plotly.js/dist/plotly.js:44:52)","    at src/core.js (/var/task/node_modules/plotly.js/dist/plotly.js:58993:7)","    at __require (/var/task/node_modules/plotly.js/dist/plotly.js:44:52)","    at lib/core.js (/var/task/node_modules/plotly.js/dist/plotly.js:59061:24)","    at __require (/var/task/node_modules/plotly.js/dist/plotly.js:44:52)"]}Feb 20, 12:36:25 PM: ERROR  Unhandled Promise Rejection 	{"errorType":"Runtime.UnhandledPromiseRejection","errorMessage":"ReferenceError: self is not defined","reason":{"errorType":"ReferenceError","errorMessage":"self is not defined","stack":["ReferenceError: self is not defined","    at node_modules/@plotly/d3/d3.js (/var/task/node_modules/plotly.js/dist/plotly.js:7261:15)","    at __require (/var/task/node_modules/plotly.js/dist/plotly.js:44:52)","    at src/lib/index.js (/var/task/node_modules/plotly.js/dist/plotly.js:15130:16)","    at __require (/var/task/node_modules/plotly.js/dist/plotly.js:44:52)","    at build/plotcss.js (/var/task/node_modules/plotly.js/dist/plotly.js:15990:17)","    at __require (/var/task/node_modules/plotly.js/dist/plotly.js:44:52)","    at src/core.js (/var/task/node_modules/plotly.js/dist/plotly.js:58993:7)","    at __require (/var/task/node_modules/plotly.js/dist/plotly.js:44:52)","    at lib/core.js (/var/task/node_modules/plotly.js/dist/plotly.js:59061:24)","    at __require (/var/task/node_modules/plotly.js/dist/plotly.js:44:52)"]},"promise":{},"stack":["Runtime.UnhandledPromiseRejection: ReferenceError: self is not defined","    at process.<anonymous> (file:///var/runtime/index.mjs:1276:17)","    at process.emit (node:events:517:28)","    at emit (node:internal/process/promises:149:20)","    at processPromiseRejections (node:internal/process/promises:283:27)","    at process.processTicksAndRejections (node:internal/process/task_queues:96:32)"]}Feb 20, 12:36:25 PM: INIT_REPORT Init Duration: 1810.41 ms	Phase: invoke	Status: error	Error Type: Runtime.UnknownFeb 20, 12:36:25 PM: Unknown application error occurred

Links:

Your Example Website or App

https://start-basic.netlify.app/

Steps to Reproduce the Bug or Issue

  1. Go to https://start-basic.netlify.app/
  2. See the error on Netlify
  3. Go to https://start-basic-gray.vercel.app/test-plotly
  4. See no error on Vercel

Expected behavior

I would expect that it would work similarly to Vercel and not show an error..

Screenshots or Videos

No response

Platform

  • OS: macOS Sonoma 14.6.1 (M1 chip)
  • Browser: Chrome 133.0.6943.98
  • Start version: 1.107.0

Additional context

No response

@serhalp
Copy link
Contributor

serhalp commented Feb 20, 2025

🤔 I wonder why this works out of the box on Vercel.

It looks like this is because d3 (a dependency of plotly.js) is only designed to work in browser environments: d3/d3#3635.

Could you give this a try with jsdom or another browser API polyfill?

@arjunyel
Copy link

This should fix it https://x.com/tannerlinsley/status/1892475211473441178

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

No branches or pull requests

3 participants