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: 'os.tmpDir is not a function' on recent Node versions #582

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

kevireilly
Copy link

@kevireilly kevireilly commented Jan 1, 2023

Brief Summary of Changes

  • Using Node version 16.16.0 and likely lower major Node versions, there is an os module breaking change where os.tmpDir() is now os.tmpdir() when running on macOS 10.15.1.
  • This appears to be resolved and/or handled by a more recent version of the connect-multiparty module.
  • Upgrading it reveals a small incompatibility where req.files.image.ws.bytesWritten is no longer available, so, a potential guess solution has been applied by using req.files.image.size instead.
  • Error observed when uploading a photo via the Add photo button on the photo-album sample:
TypeError: os.tmpDir is not a function
    at new Form (/Users/kevinreilly/Development/cloudinary_npm/samples/photo_album/node_modules/multiparty/index.js:55:44)
    at multipart (/Users/kevinreilly/Development/cloudinary_npm/samples/photo_album/node_modules/connect-multiparty/index.js:56:16)
    at Layer.handle [as handle_request] (/Users/kevinreilly/Development/cloudinary_npm/samples/photo_album/node_modules/express/lib/router/layer.js:95:5)
    at next (/Users/kevinreilly/Development/cloudinary_npm/samples/photo_album/node_modules/express/lib/router/route.js:144:13)
    at Route.dispatch (/Users/kevinreilly/Development/cloudinary_npm/samples/photo_album/node_modules/express/lib/router/route.js:114:3)
    at Layer.handle [as handle_request] (/Users/kevinreilly/Development/cloudinary_npm/samples/photo_album/node_modules/express/lib/router/layer.js:95:5)
    at /Users/kevinreilly/Development/cloudinary_npm/samples/photo_album/node_modules/express/lib/router/index.js:284:15
    at Function.process_params (/Users/kevinreilly/Development/cloudinary_npm/samples/photo_album/node_modules/express/lib/router/index.js:346:12)
    at next (/Users/kevinreilly/Development/cloudinary_npm/samples/photo_album/node_modules/express/lib/router/index.js:280:10)
    at /Users/kevinreilly/Development/cloudinary_npm/samples/photo_album/server.js:53:7

What Does This PR Address?

  • GitHub issue (Add reference - #XX)
  • Refactoring
  • New feature
  • Bug fix
  • Adds more tests

Are Tests Included?

  • Yes
  • No

Reviewer, Please Note:

Decision to replace req.files.image.ws.bytesWritten with req.files.image.size may not be correct as the former no longer appears to be available with an upgraded version of connect-multiparty, though I'm not certain this meets the original expectations of evaluating the bytesWritten.

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.

1 participant