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

"Class extends value #<newConstructor> is not a constructor or null" when sending request from node.js 20.12.0 #6340

Open
mattwatts-aimltd-uk opened this issue Apr 3, 2024 · 2 comments

Comments

@mattwatts-aimltd-uk
Copy link

mattwatts-aimltd-uk commented Apr 3, 2024

Describe the issue

Hi all,

After recently trying to upgrade from node.js 18.18.1 to the latest LTS (20.12.0) my Axios requests are failing with the below error:

TypeError: Class extends value #<newConstructor> is not a constructor or null
	at lib/websocket/events.js (node:internal/deps/undici/undici:11139:52)
	at __require (node:internal/deps/undici/undici:6:50)
	at lib/websocket/util.js (node:internal/deps/undici/undici:11390:40)
	at __require (node:internal/deps/undici/undici:6:50)
	at lib/websocket/websocket.js (node:internal/deps/undici/undici:11951:96)
	at __require (node:internal/deps/undici/undici:6:50)
	at node:internal/deps/undici/undici:12353:28
	at BuiltinModule.compileForInternalLoader (node:internal/bootstrap/realm:398:7)
	at requireBuiltin (node:internal/bootstrap/realm:429:14)
	at get FormData (node:internal/util:606:15)
	at Object.isFormData (/var/api/node_modules/axios/lib/utils.js:192:3)
	at Object.transformRequest (/var/api/node_modules/axios/lib/defaults/index.js:51:30)
	at transform (/var/api/node_modules/axios/lib/core/transformData.js:22:15)
	at Object.forEach (/var/api/node_modules/axios/lib/utils.js:255:10)
	at Object.transformData (/var/api/node_modules/axios/lib/core/transformData.js:21:9)
	at Axios.dispatchRequest (/var/api/node_modules/axios/lib/core/dispatchRequest.js:40:31)
	at Axios._request (/var/api/node_modules/axios/lib/core/Axios.js:170:33)
	at Axios.request (/var/api/node_modules/axios/lib/core/Axios.js:40:25)
	at Axios.httpMethod [as post] (/var/api/node_modules/axios/lib/core/Axios.js:209:19)
	at Function.post (/var/api/node_modules/axios/lib/helpers/bind.js:5:15)
	at authenticate (/var/api/api/services/IntegrationEngine/AuthProvider/AccessToken.ts:113:44)
	at processTicksAndRejections (node:internal/process/task_queues:95:5)
	at async prepareAndRequest (/var/api/api/services/IntegrationEngine/RequestEndpointIntegration.ts:692:24)
	at async Object.prepareAndRequest (/var/api/api/services/IntegrationEngine/RequestEndpointIntegration.ts:725:20)
	at async Object.processStep (/var/api/api/services/IntegrationEngine/StepProcessor.ts:133:28)
	at async Object.processIntegrationFlow (/var/api/api/services/IntegrationEngine/FlowProcessor.ts:328:17)
	at Axios.request (/var/api/node_modules/axios/lib/core/Axios.js:45:41)
	at processTicksAndRejections (node:internal/process/task_queues:95:5)

Reverting back to the old node version prevents this from being an issue. As far as I can see, this breaks when I move from Node.js 18.18.1 to any version >= 18.18.2, as that experiences the same issue.

This seems to only be an issue where I'm sending a request with qs.stringify(data) in the body, but can't see any incompatibilities between this version of Node and QS.

I'm running Axios within a Dockerized Node.js container.

Does anyone have any idea as to why this might be happening?

Example Code

const axiosClient = axios.create({
    timeout: 30000,
    headers: {
        'Content-Type': 'application/x-www-form-urlencoded',
    },
});


const response = await axiosClient.post(
            url,
            qs.stringify(body)
        );

Expected behavior

Axios should send and receive the HTTP request in the same manner between Node versions.

Axios Version

1.6.8

Adapter Version

No response

Browser

No response

Browser Version

No response

Node.js Version

20.12.0

OS

No response

Additional Library Versions

No response

Additional context/Screenshots

No response

@mattwatts-aimltd-uk mattwatts-aimltd-uk changed the title "Class extends value #<newConstructor> is not a constructor or null "Class extends value #<newConstructor> is not a constructor or null" when sending request from node.js 20.12.0 Apr 3, 2024
@DigitalBrainJS
Copy link
Collaborator

20.12.0
18.18.2

I can't reproduce the issue using your example in both versions. Have you tested this on your example?

@jcowley
Copy link

jcowley commented May 1, 2024

We've been hampered by this issue for months and are stuck on node v18.18.1 because of it. We don't use axios directly in our project, but the @slack/web-api and stream-chat libraries that we use in our project both use axios. I have no idea if axios is the real source of the issue here, but the error occurs anytime those libraries try to make an http request on node v18.18.2 or higher via axios.

Our "fix" is to downgrade to node v18.18.1. As @mattwatts-aimltd-uk says, anything v18.18.2 or greater gets this same error.

Here's what we see when the stream-chat library tries to make a request via axios on node > v18.18.2

2024-05-01T21:17:35.903Z - error: Error accessing stream messaging message=Class extends value #<child> is not a constructor or null, stack=TypeError: Class extends value #<child> is not a constructor or null
    at lib/websocket/events.js (node:internal/deps/undici/undici:10194:52)
    at __require (node:internal/deps/undici/undici:4:50)
    at lib/websocket/util.js (node:internal/deps/undici/undici:10436:40)
    at __require (node:internal/deps/undici/undici:4:50)
    at lib/websocket/websocket.js (node:internal/deps/undici/undici:10979:96)
    at __require (node:internal/deps/undici/undici:4:50)
    at node:internal/deps/undici/undici:11380:28
    at BuiltinModule.compileForInternalLoader (node:internal/bootstrap/loaders:336:7)
    at requireBuiltin (node:internal/bootstrap/loaders:367:14)
    at lazyUndici (node:internal/process/pre_execution:237:14)
    at get (node:internal/process/pre_execution:252:16)
    at Object.isFormData (/poached/poached-web/server/node_modules/stream-chat/node_modules/axios/dist/node/axios.cjs:219:3)
    at Object.transformRequest (/poached/poached-web/server/node_modules/stream-chat/node_modules/axios/dist/node/axios.cjs:1453:32)
    at transform (/poached/poached-web/server/node_modules/stream-chat/node_modules/axios/dist/node/axios.cjs:1921:15)
    at Object.forEach (/poached/poached-web/server/node_modules/stream-chat/node_modules/axios/dist/node/axios.cjs:282:10)
    at Object.transformData (/poached/poached-web/server/node_modules/stream-chat/node_modules/axios/dist/node/axios.cjs:1920:11)
    at Axios.dispatchRequest (/poached/poached-web/server/node_modules/stream-chat/node_modules/axios/dist/node/axios.cjs:3611:31)
    at Axios._request (/poached/poached-web/server/node_modules/stream-chat/node_modules/axios/dist/node/axios.cjs:4001:33)
    at Axios.request (/poached/poached-web/server/node_modules/stream-chat/node_modules/axios/dist/node/axios.cjs:3871:25)
    at Axios.httpMethod [as post] (/poached/poached-web/server/node_modules/stream-chat/node_modules/axios/dist/node/axios.cjs:4040:19)
    at Function.wrap [as post] (/poached/poached-web/server/node_modules/stream-chat/node_modules/axios/dist/node/axios.cjs:28:15)
    at _callee5$ (/poached/poached-web/server/node_modules/stream-chat/dist/index.js:7450:44)
    at tryCatch (/poached/poached-web/server/node_modules/@babel/runtime/helpers/regeneratorRuntime.js:45:16)
    at Generator.<anonymous> (/poached/poached-web/server/node_modules/@babel/runtime/helpers/regeneratorRuntime.js:133:17)
    at Generator.next (/poached/poached-web/server/node_modules/@babel/runtime/helpers/regeneratorRuntime.js:74:21)
    at asyncGeneratorStep (/poached/poached-web/server/node_modules/@babel/runtime/helpers/asyncToGenerator.js:3:24)
    at _next (/poached/poached-web/server/node_modules/@babel/runtime/helpers/asyncToGenerator.js:22:9)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at Axios.request (/poached/poached-web/server/node_modules/stream-chat/node_modules/axios/dist/node/axios.cjs:3876:41)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5), client_request_id=a6aaaf67-03ce-41c2-b100-825f9e09a2b1

Similar error when we the @slack/web-api tries to make an http request via axios:

Error posting to slack message=Class extends value #<child> is not a constructor or null, stack=TypeError: Class extends value #<child> is not a constructor or null
    at lib/websocket/events.js (node:internal/deps/undici/undici:10194:52)
    at __require (node:internal/deps/undici/undici:4:50)
    at lib/websocket/util.js (node:internal/deps/undici/undici:10436:40)
    at __require (node:internal/deps/undici/undici:4:50)
    at lib/websocket/websocket.js (node:internal/deps/undici/undici:10979:96)
    at __require (node:internal/deps/undici/undici:4:50)
    at node:internal/deps/undici/undici:11380:28
    at BuiltinModule.compileForInternalLoader (node:internal/bootstrap/loaders:336:7)
    at requireBuiltin (node:internal/bootstrap/loaders:367:14)
    at lazyUndici (node:internal/process/pre_execution:237:14)
    at get (node:internal/process/pre_execution:252:16)
    at Object.isFormData (/poached/poached-web/server/node_modules/@slack/web-api/node_modules/axios/lib/utils.js:191:3)
    at dispatchHttpRequest (/poached/poached-web/server/node_modules/@slack/web-api/node_modules/axios/lib/adapters/http.js:92:15)
    at new Promise (<anonymous>)
    at httpAdapter (/poached/poached-web/server/node_modules/@slack/web-api/node_modules/axios/lib/adapters/http.js:49:10)
    at dispatchRequest (/poached/poached-web/server/node_modules/@slack/web-api/node_modules/axios/lib/core/dispatchRequest.js:58:10)
    at Axios.request (/poached/poached-web/server/node_modules/@slack/web-api/node_modules/axios/lib/core/Axios.js:109:15)
    at Axios.httpMethod [as post] (/poached/poached-web/server/node_modules/@slack/web-api/node_modules/axios/lib/core/Axios.js:144:19)
    at Function.wrap [as post] (/poached/poached-web/server/node_modules/@slack/web-api/node_modules/axios/lib/helpers/bind.js:9:15)
    at /poached/poached-web/server/node_modules/@slack/web-api/dist/WebClient.js:260:51
    at run (/poached/poached-web/server/node_modules/@slack/web-api/node_modules/p-queue/dist/index.js:157:104)
    at PQueue._tryToStartAnother (/poached/poached-web/server/node_modules/@slack/web-api/node_modules/p-queue/dist/index.js:105:17)
    at /poached/poached-web/server/node_modules/@slack/web-api/node_modules/p-queue/dist/index.js:171:18
    at new Promise (<anonymous>)
    at PQueue.add (/poached/poached-web/server/node_modules/@slack/web-api/node_modules/p-queue/dist/index.js:152:16)
    at task (/poached/poached-web/server/node_modules/@slack/web-api/dist/WebClient.js:257:46)
    at RetryOperation._fn (/poached/poached-web/server/node_modules/p-retry/index.js:50:18)
    at RetryOperation.attempt (/poached/poached-web/server/node_modules/p-retry/node_modules/retry/lib/retry_operation.js:116:8)

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