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

fix: AbortController is not defined on Node.js (Server Side Render) #3169

Merged
merged 2 commits into from
Sep 13, 2021
Merged

fix: AbortController is not defined on Node.js (Server Side Render) #3169

merged 2 commits into from
Sep 13, 2021

Conversation

onhate
Copy link
Contributor

@onhate onhate commented Sep 3, 2021

closes #3168

Copy link
Contributor

@aduh95 aduh95 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure this fixes anything, this module is not using strict mode so an undeclared global should not be a problem.
As I said on the issue, it's more likely a configuration problem: Uppy expects AbortController to be available globally, leaving it as undefined it's likely to cause problem down the road and create undefined behavior. A better workaround would be to make AbortController and AbortSignal available as globals on your env (either by using --experimental-abortcontroller CLI flag, either by using polyfill).

packages/@uppy/utils/src/AbortController.js Outdated Show resolved Hide resolved
@aduh95
Copy link
Contributor

aduh95 commented Sep 6, 2021

I'm not sure this fixes anything, this module is not using strict mode so an undeclared global should not be a problem.

I was wrong on this, the file that ends up on npm is using strict mode: https://unpkg.com/@uppy/[email protected]/lib/AbortController.js
That's probably appended by the build chain, and explains the error you're seeing.

@onhate
Copy link
Contributor Author

onhate commented Sep 6, 2021

The issue I'm facing is that this code runs on node.js instead of the browser when it's used on SSR frameworks like Nuxt, Next.js, Gatsby....

The check of the typeof is the way SSR servers check if they are running on server or client and it works fine. This is not meant to run uppy on server side, instead it just allows it to be imported on the server code that will generate the HTMLs (on Server Side Rendered) that the client will use.

@onhate onhate changed the title fix: AbortController is not defined fix: AbortController is not defined on Node.js (Server Side Render) Sep 6, 2021
@onhate
Copy link
Contributor Author

onhate commented Sep 13, 2021

hi @aduh95, what are the plans for this fix?

Co-authored-by: Antoine du Hamel <[email protected]>
@onhate onhate requested a review from aduh95 September 13, 2021 12:43
@Murderlon
Copy link
Member

@aduh95 you can merge this if it's ready

@aduh95 aduh95 merged commit c7e0a5a into transloadit:main Sep 13, 2021
@onhate onhate deleted the fix-AbortController-is-not-defined branch September 13, 2021 12:56
Murderlon added a commit that referenced this pull request Sep 20, 2021
* main:
  Show all details on mobile when `showProgressDetails` is `true` (#3174)
  @uppt/xhr-upload: fix `this.uppy is undefined` error (#3207)
  ci: test on Node.js v16.x (#3205)
  @uppy/dashboard: fix linter (#3206)
  Add `2.1.1` to `CHANGELOG.md`
  Release
  Release
  Fix "attempted to use private field on non-instance" in `SearchProvider` (#3201)
  Add 'done' to `nb_NO.js` (#3200)
  @uppy/transloadit: fix unhandledPromiseRejection failures (#3197)
  fix: AbortController is not defined on Node.js (Server Side Render) (#3169)
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

Successfully merging this pull request may close these issues.

[v2] AbortController is not defined on @uppy/aws-s3-multipart when SSR
3 participants