I'm using the --cpu-prof
flag to generate a cpuprofile
of my Node.js 18.16.0 application. When I try to initiate the creation of the cpuprofile
, I get this error: Failed to convert CPU profile message to V8 string
.
I'm hosting my app in a Docker container within Azure App Service. This error hasn't appeared anywhere else on the Internet - What does it mean, and how can I resolve it?
Dockerfile:
FROM node:18-alpine AS builder
WORKDIR /build
COPY . .
RUN npm ci
RUN npm run compile
CMD ["npm", "start"]
If you are running the Node app in Docker container, to use --cpu-prof
you need to give the command in the Dockerfile
.
This worked for me:
I am using a simple node express app.
Dockerfile
:
FROM node:lts-alpine
ENV NODE_ENV=production
WORKDIR /usr/src/app
COPY ["package.json", "package-lock.json*", "npm-shrinkwrap.json*", "./"]
RUN npm install --production --silent && mv node_modules ../
COPY . .
EXPOSE 3000
RUN chown -R node /usr/src/app
USER node
CMD ["node","--cpu-prof","--prof", "app.js"]
OUTPUT
:I am able to see my cpu profile file inside the container
To access file use this commands:
open interactive cell:
docker exec -it <container_name_or_id> sh
To Copy the file from container you can run this command
docker cp 938843ef2767:/usr/src/app/isolate-0x7fdafe318690-1-v8.log .
Note : used
.
for copying to current folder.
EDIT
:To check the files in Azure follow the following steps:
Azure Container Registry
and push the docker image to registry.Access Key
and enable Admin user
Containers
->Connect
->/bin/sh
for Linux.