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

mime.charsets in Response.js is undefined #5567

Closed
robertlario opened this issue Mar 27, 2024 · 8 comments
Closed

mime.charsets in Response.js is undefined #5567

robertlario opened this issue Mar 27, 2024 · 8 comments
Labels

Comments

@robertlario
Copy link

Using Express version 4.19.2 in Response.js at line 790 (var charset = mime.charsets.lookup(value.split(';')[0]);) is throwing an exception stating that mime.charset "TypeError: Cannot read properties of undefined (reading 'charsets')"

@wesleytodd
Copy link
Member

Can you post some example code where it is having this error behavior?

@robertlario
Copy link
Author

robertlario commented Mar 27, 2024

I am trying to run my code in serverless-offline.

I do not call the code directly.

Here is the stack trace:

TypeError: Cannot read properties of undefined (reading 'charsets')
at ServerResponse.header (..\node_modules\express\lib\response.js:790:1)
at ServerResponse.contentType (..\node_modules\express\lib\response.js:625:1)
at setContentTypeMiddleware (..\lib\router\middlewares\setContentType.js:15:1)
at Layer.handle [as handle_request] (..\node_modules\express\lib\router\layer.js:95:1)
at trim_prefix (..\node_modules\express\lib\router\index.js:328:1)
at ..\node_modules\express\lib\router\index.js:286:1
at Function.process_params (..\node_modules\express\lib\router\index.js:346:1)
at next (..\node_modules\express\lib\router\index.js:280:1)
at ..\lib\router\middlewares\setServerUrl.js:26:1
at .webpack\service\src\index.js:154906:9 {stack: 'TypeError: Cannot read properties of undefine…oyment.webpack\service\src\index.js:154906:9', message: 'Cannot read properties of undefined (reading 'charsets')'}

Here are my modules:
@types/cors@2.8.17
├── @types/errorhandler@0.0.32
├── @types/express-serve-static-core@4.17.43
├── @types/express@4.17.21
├── @types/flat@5.0.5
├── @types/http-errors@1.8.2
├── @types/jest@26.0.24
├── @types/lodash@4.14.202
├── @types/mime-types@2.1.4
├── @types/mock-req-res@1.1.6
├── @types/node@12.20.55
├── @types/uuid@3.4.13
├── @typescript-eslint/eslint-plugin@4.33.0
├── @typescript-eslint/parser@4.33.0
├── ajv-errors@1.0.1
├── ajv@6.12.6
├── aws-sdk-mock@5.9.0
├── aws-sdk@2.1573.0
├── aws-xray-sdk@3.5.4
├── cors@2.8.5
├── errorhandler@1.5.1
├── eslint-config-airbnb-base@14.2.1
├── eslint-config-prettier@8.10.0
├── eslint-plugin-import@2.29.1
├── eslint-plugin-prettier@4.2.1
├── eslint@7.32.0
├── express@4.19.2
├── flat@5.0.2
├── force@0.0.3
├── http-errors@1.8.1
├── jest-each@26.6.2
├── jest-mock-extended@1.0.18
├── jest@26.6.3
├── lodash@4.17.21
├── mime-types@2.1.35
├── mime@4.0.1
├── mock-req-res@1.2.1
├── prettier@2.8.8
├── serverless-http@2.7.0
├── sinon@10.0.1
├── standard-version@9.5.0
├── supertest@6.3.4
├── ts-jest@26.5.6
├── typescript@4.9.5
├── uuid@8.3.2

@wesleytodd
Copy link
Member

I don't know what serverless offline is, but in the stack I see this is the closes thing that looks like user land code: at ..\lib\router\middlewares\setServerUrl.js:26:1

@robertlario
Copy link
Author

at line 34 in response.js

var mime = send.mime;

send.mime appears to be undefined.

Any thoughts?

@wesleytodd
Copy link
Member

https://github.com/pillarjs/send/blob/master/index.js#L71

I looked at that initially and am not sure how it could be. That is why I would need more to go off of to debug.

@wesleytodd
Copy link
Member

Also, the npm ls output you showed doesn't show these things afaict. If you think it is something with the packages installed please post more of the output.

@robertlario
Copy link
Author

It was a versioning issue! :-( What a nightmare!

Please consider the issue closed. Thank you for your help!

@wesleytodd
Copy link
Member

Haha, no problem. Glad you got it sorted out!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants