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

unstable_parseMultipartFormData causes "ReferenceError: Buffer is not defined" error #2409

Closed
gabimor opened this issue Mar 20, 2022 · 6 comments
Labels
bug:unverified duplicate This issue or pull request already exists

Comments

@gabimor
Copy link
Contributor

gabimor commented Mar 20, 2022

What version of Remix are you using?

1.2.3

Steps to Reproduce

  1. create a remix route route with an action (just an action, no loader or export default Component)
  2. import unstable_parseMultipartFormData to that file and use it
  3. when accessing that route the browser console errors with "ReferenceError: Buffer is not defined"

adding a default export solves this:

export default function Index() {
  return ""
}

Expected Behavior

not sure what the issue is but there should be a better error explaining it. and to my understanding this should just work even without a component export

Actual Behavior

"ReferenceError: Buffer is not defined" in the browser

@herrmannplatz
Copy link

Guess you need to define your uploadHandler inside the action function. Run into the same issue when following the docs.

https://github.com/remix-run/remix/blob/main/examples/file-and-cloudinary-upload/app/routes/local-upload.tsx

@gabimor
Copy link
Contributor Author

gabimor commented Mar 21, 2022

I think i tried that, but why does defining a component export solve that?

@kiliman
Copy link
Collaborator

kiliman commented Mar 21, 2022

@gabimor It's hard to say without seeing the actual route file. Can you post it? You can remove any private code.

@MichaelDeBoey
Copy link
Member

This seems to be related to #2248

@chaance
Copy link
Collaborator

chaance commented Apr 8, 2022

Duplicate of #2248, working on it! Will update there when we can.

@chaance chaance closed this as completed Apr 8, 2022
@shymarrai
Copy link

for me what worked was:

import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import path from 'path'
import inject from '@rollup/plugin-inject'

export default defineConfig({
plugins: [vue()],
resolve: {
alias: {
'@': path.resolve(__dirname, 'src'),
}
},
build: {
rollupOptions: {
plugins: [inject({ Buffer: ['buffer', 'Buffer'] })],
},
},
})

reply to this comment:

vitejs/vite#2785 (reply in thread)

@MichaelDeBoey MichaelDeBoey added the duplicate This issue or pull request already exists label Jul 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug:unverified duplicate This issue or pull request already exists
Projects
None yet
Development

No branches or pull requests

6 participants