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

self is not defined on server #47

Closed
clintonwoo opened this issue Aug 29, 2015 · 2 comments
Closed

self is not defined on server #47

clintonwoo opened this issue Aug 29, 2015 · 2 comments

Comments

@clintonwoo
Copy link

In my react-relay project I had to change 'self' variables in the following files to 'global' to get the Node server to run... I couldn't run a server using Relay without the change.

/react-relay/node_modules/fbjs/lib/fetch.js
/react-relay/node_modules/fbjs/node_modules/whatwg-fetch/fetch.js

Error given was:
ReferenceError: self is not defined
[1] at /node_modules/react-relay/node_modules/fbjs/node_modules/whatwg-fetch/fetch.js:4:7
[1] at Object. (/node_modules/react-relay/node_modules/fbjs/node_modules/whatwg-fetch/fetch.js:330:3)
[1] at Module._compile (module.js:460:26)
[1] at Module._extensions..js (module.js:478:10)
[1] at Object.require.extensions.(anonymous function) as .js
[1] at Module.load (module.js:355:32)
[1] at Module._load (module.js:310:12)
[1] at Function.module._load (/node_modules/piping/lib/launcher.js:32:16)
[1] at Module.require (module.js:365:17)
[1] at require (module.js:384:17)

@zpao
Copy link
Member

zpao commented Aug 31, 2015

cc @steveluscher who I think I can at least partially blame for this 😜

I thought we weren't going to get into a situation where fetch was actually used in node?

@steveluscher
Copy link
Contributor

Hi @clintonwoo. Are you trying to execute a Relay app on the server side in Node? If you are, and you're using the default network layer that imports fetch, it will break.

github/fetch is meant to be a browser polyfill only and they have no plans to make it universal.

What you should likely do, is to create (and inject) a network layer specific for the server side. Since you're already on the server, you might not even have to make network calls – you might choose to craft a network layer that resolves your queries in-place. See the Network Layer guide for more information.

Let's close this issue here. If you want to continue the conversation about your server-side Relay use-case, please do open an issue on the Relay issue tracker!

See also: 675d80a#commitcomment-12454443

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