Hello,
I'm trying to use the @sentry/sentry-webpack-plugin in a project with a Docker from node:alpine and my webpack build is giving the following errors:
Note: I launch the build with this: docker build --tag=api . --build-arg SENTRY_ORG=my-org --build-arg SENTRY_AUTH_TOKEN=my-auth-token
Step 17/21 : RUN yarn build
---> Running in 2b914c65edc5
yarn run v1.15.2
$ backpack build
(node:33) UnhandledPromiseRejectionWarning: Error: spawn Unknown system error -8
at ChildProcess.spawn (internal/child_process.js:373:11)
at spawn (child_process.js:559:9)
at Object.execFile (child_process.js:224:15)
at Promise (/usr/src/api/node_modules/@sentry/cli/js/helper.js:147:20)
at new Promise (<anonymous>)
at Object.execute (/usr/src/api/node_modules/@sentry/cli/js/helper.js:137:10)
at Object.proposeVersion (/usr/src/api/node_modules/@sentry/cli/js/releases/index.js:57:8)
at SentryCliPlugin.getReleasePromise (/usr/src/api/node_modules/@sentry/webpack-plugin/src/index.js:162:27)
at new SentryCliPlugin (/usr/src/api/node_modules/@sentry/webpack-plugin/src/index.js:112:25)
at Object.webpack (/usr/src/api/backpack.config.js:24:9)
(node:33) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 2)
(node:33) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
(node:33) PromiseRejectionHandledWarning: Promise rejection was handled asynchronously (rejection id: 2)
(node:33) UnhandledPromiseRejectionWarning: Error: spawn Unknown system error -8
at ChildProcess.spawn (internal/child_process.js:373:11)
at spawn (child_process.js:559:9)
at Object.execFile (child_process.js:224:15)
at Promise (/usr/src/api/node_modules/@sentry/cli/js/helper.js:147:20)
at new Promise (<anonymous>)
at Object.execute (/usr/src/api/node_modules/@sentry/cli/js/helper.js:137:10)
at Object.proposeVersion (/usr/src/api/node_modules/@sentry/cli/js/releases/index.js:57:8)
at SentryCliPlugin.getReleasePromise (/usr/src/api/node_modules/@sentry/webpack-plugin/src/index.js:162:27)
at new SentryCliPlugin (/usr/src/api/node_modules/@sentry/webpack-plugin/src/index.js:112:25)
at Object.webpack (/usr/src/api/backpack.config.js:24:9)
(node:33) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 3)
Isolating the cli call, I have the following error on docker build:
Step 17/25 : RUN npx sentry-cli
---> Running in 3ee1764e848e
spawn Unknown system error -8
The command '/bin/sh -c npx sentry-cli' returned a non-zero code: 1
Isolating the package in node:alpine:
FROM node:alpine
RUN yarn add @sentry/webpack-plugin
RUN npx sentry-cli
Gives me the following output:
Step 1/3 : FROM node:alpine
---> 953c516e1466
Step 2/3 : RUN yarn add @sentry/webpack-plugin
---> Running in 476725a750e7
yarn add v1.15.2
info No lockfile found.
[1/4] Resolving packages...
[2/4] Fetching packages...
[3/4] Linking dependencies...
[4/4] Building fresh packages...
success Saved lockfile.
success Saved 14 new dependencies.
info Direct dependencies
鈹斺攢 @sentry/[email protected]
info All dependencies
鈹溾攢 @sentry/[email protected]
鈹溾攢 @sentry/[email protected]
鈹溾攢 [email protected]
鈹溾攢 [email protected]
鈹溾攢 [email protected]
鈹溾攢 [email protected]
鈹溾攢 [email protected]
鈹溾攢 [email protected]
鈹溾攢 [email protected]
鈹溾攢 [email protected]
鈹溾攢 [email protected]
鈹溾攢 [email protected]
鈹溾攢 [email protected]
鈹斺攢 [email protected]
Done in 3.38s.
Removing intermediate container 476725a750e7
---> c7784ba53137
Step 3/3 : RUN npx sentry-cli
---> Running in 985421737f8a
internal/modules/cjs/loader.js:657
throw err;
^
Error: Cannot find module '/root/.npm/_npx/1/lib/node_modules/sentry-cli/tasks/download.js'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:655:15)
at Function.Module._load (internal/modules/cjs/loader.js:580:25)
at Function.Module.runMain (internal/modules/cjs/loader.js:868:12)
at internal/main/run_main_module.js:21:11
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] postinstall: `node tasks/download.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] postinstall script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /root/.npm/_logs/2019-04-08T21_47_01_099Z-debug.log
Install for sentry-cli@latest failed with code 1
The command '/bin/sh -c npx sentry-cli' returned a non-zero code: 1
I'm not sure what am I doing wrong right now. Are there some packages I should add to node:alpine so the cli works?
Thank you for your time.
Same here :(
Same here :(
Any solution ?
It is not related with alpine, same issue on node:lts and node:lts-buster docker image, see #620
A few notes here:
@sentry/cli, not sentry-cli.npx @sentry/cli should work under root after you do npm config set unsafe-perm trueFeel free to provide another minimal failing example.
This should be resolved by now, see https://github.com/getsentry/sentry-cli/issues/620#issuecomment-584194880 + commit from Tonyo.
@kamilogorek I'm still getting this error on "@sentry/cli": "^1.51.1".
I tried on a node:slim image as well and am getting:
/usr/src/app/node_modules/@sentry/cli/sentry-cli: 1: /usr/src/app/node_modules/@sentry/cli/sentry-cli: Syntax error: "(" unexpected
Any idea what's up?
@lightninglu10 can you provide your Dockerfile?
FROM node:alpine
# install dependencies
RUN apk add --no-cache --virtual .build-deps \
git \
python \
make \
g++
# Create app directory
RUN mkdir -p /usr/src/app
WORKDIR /usr/src/app
COPY package.json /usr/src/app
COPY yarn.lock /usr/src/app
COPY .sentryclirc /usr/src/app
# install yarn and yarn install
RUN yarn install --production --no-progress
# Expose the public http port
EXPOSE 3000
# Bundle app source
COPY . /usr/src/app
ARG REACT_APP_ENV
ENV REACT_APP_ENV=$REACT_APP_ENV
ARG SENTRY_RELEASE
RUN SENTRY_RELEASE=${SENTRY_RELEASE} REACT_APP_ENV=${REACT_APP_ENV} yarn run build
RUN SENTRY_RELEASE=${SENTRY_RELEASE} yarn run sentry;
# build and Start server
CMD ["yarn", "start"]
Where yarn run sentry runs a node.js file
const SentryCli = require("@sentry/cli");
async function createReleaseAndUpload() {
const release = process.env.SENTRY_RELEASE;
if (!release) {
console.warn("SENTRY_RELEASE is not set");
return;
}
const cli = new SentryCli();
try {
console.log("Creating sentry release " + release);
await cli.releases.new(release);
console.log("Uploading source maps");
await cli.releases.uploadSourceMaps(release, {
include: [".next/server/static/"],
urlPrefix: "~/static/js",
rewrite: false,
});
console.log("Finalizing release");
await cli.releases.finalize(release);
} catch (e) {
console.error("Source maps uploading failed:", e);
}
}
createReleaseAndUpload();
Unfortunately provided code isn't enough to reproduce the issue. I need a valid repro case for this to investigate.
The same problem as @lightninglu10 faced - working locally on OSX, but does not work in the docker container (tried node:10-alpine image also):
FROM node:13.12.0-stretch
ENV PATH="${PATH}:/root/.local/bin"
RUN apt-get update && apt-get -f --yes install curl python python-pip git \
&& (curl --compressed -o- -L https://yarnpkg.com/install.sh | bash) \
&& (curl --compressed -o- -L https://sentry.io/get-cli/ | bash) \
&& pip install awscli --upgrade --user
Running sentry-cli from PATH works as expected, but running through NODE returns:
/app/node_modules/@sentry/cli/sentry-cli: 1: /app/node_modules/@sentry/cli/sentry-cli: Syntax error: end of file unexpected (expecting ")")
I guess there is something with node_modules/@sentry/cli/sentry-cli binary, @kamilogorek could you please help?
Temporary fix to patch path to OS installed sentry-cli in the package.json:
"postinstall": "sed -e \"s/return binaryPath;/return '/usr/local/bin/sentry-cli';/g\" -i.bak ./node_modules/@sentry/cli/js/helper.js"
Most helpful comment
The same problem as @lightninglu10 faced - working locally on OSX, but does not work in the docker container (tried node:10-alpine image also):
Running sentry-cli from PATH works as expected, but running through NODE returns:
/app/node_modules/@sentry/cli/sentry-cli: 1: /app/node_modules/@sentry/cli/sentry-cli: Syntax error: end of file unexpected (expecting ")")I guess there is something with
node_modules/@sentry/cli/sentry-clibinary, @kamilogorek could you please help?Temporary fix to patch path to OS installed sentry-cli in the
package.json: