ERR_INVALID_ARG_TYPE The "data" argument must be of type string or an instance of Buffer, TypedArray, or DataView. Received undefined. Only on Docker

  cypress, docker, node.js, typescript

My goal is to run Cypress tests used for my test stage in a pipeline on GitLab. Originally I used an alpine:3.13 image.

There I install all the dependencies. The app consists of two TypeScript based components, which I will call front and back. Each have an application part and an API.

I run the following command to set up front and back and finally execute cypress in headless mode:

"e2e:run": "concurrently -n front, back "yarn front" "yarn back" "yarn front:wait && yarn back:wait && yarn cypress:run""

On the alpine image it builds and runs front and back successful, but as I later found out, Cypress has dependencies that are not available on alpine.

So I tried using the images that Cypress provides (https://github.com/cypress-io/cypress-docker-images/tree/master/base). There are mostly Debian based images available, but I also tried Ubuntu with different versions of Node each. On the Debian images I get the following error, indicating problems running the API of my "front" and "back" application:

#41 240.0 [back] [api] (node:515) UnhandledPromiseRejectionWarning: TypeError [ERR_INVALID_ARG_TYPE]: The "data" argument must be of type string or an instance of Buffer, TypedArray, or DataView. Received undefined
#41 240.0 [back] [api]     at Object.writeFile (fs.js:1487:5)
#41 240.0 [back] [api]     at /app/.pnp.js:36413:21
#41 240.0 [back] [api]     at new Promise (<anonymous>)
#41 240.0 [back] [api]     at NodeFS.writeFilePromise (/app/.pnp.js:36407:18)
#41 240.0 [back] [api]     at makeCallPromise.async.subPath.subPath (/app/.pnp.js:39147:32)
#41 240.0 [back] [api]     at ZipOpenFS.makeCallPromise (/app/.pnp.js:39430:32)
#41 240.0 [back] [api]     at ZipOpenFS.writeFilePromise (/app/.pnp.js:39146:23)
#41 240.0 [back] [api]     at VirtualFS.writeFilePromise (/app/.pnp.js:36752:24)
#41 240.0 [back] [api]     at PosixFS.writeFilePromise (/app/.pnp.js:36752:24)
#41 240.0 [back] [api]     at /app/.pnp.js:39852:20

The same error also occurs for the front API. My Dockerfile has the following structure:

FROM cypress/base:14.15.4 as dependencies
ARG A
ARG B
ARG C
ARG D
WORKDIR /app
COPY .yarn ./.yarn
COPY package.json yarn.lock tsconfig.json .yarnrc.yml jest.config.js .lighthouserc.json ./

ENV A=${A}
ENV B=${B}
ENV C=${C}
ENV D=${D}

COPY dirName/package.json ./dirName/package.json
COPY dirName/package.json ./dirName/package.json
COPY dirName/package.json ./dirName/package.json
COPY back/webapp/package.json ./back/webapp/package.json
COPY back/api/package.json ./back/api/package.json
COPY front/api/package.json ./front/api/package.json
COPY front/webapp/package.json ./front/webapp/package.json
COPY dirName/package.json ./dirName/package.json
COPY dirName/package.json ./dirName/package.json
COPY tests/package.json ./tests/package.json

RUN yarn

COPY dirName1 ./dirName1
COPY dirName2 ./dirName2
COPY dirName3 ./dirName3
COPY dirName4 ./dirName4
COPY back/webapp ./back/webapp
COPY back/api ./back/api
COPY front/api ./front/api
COPY front/webapp ./front/webapp
COPY tests ./tests

RUN cd dirName && yarn run tsc
RUN cd dirName && yarn run tsc
RUN cd dirName && yarn run tsc
RUN cd dirName && yarn build
RUN cd back/api && yarn run tsc
RUN cd front/api && yarn run tsc

RUN yarn run e2e:run

The .pnp.js file is created when running yarn, but what could be the reason for this error only appearing in a Debian based image?
Is there a way to get more details about the origin of the error? Now I only know something is undefined, but not what.

Source: Docker Questions

LEAVE A COMMENT