Task runner issue with external module

Describe the problem/error/question

I tried to activate task runner via env var “N8N_RUNNERS_ENABLED=true”. But when this task runner is activated I have the following error in my code node that use puppeteer

For info, I update my Dockerfile to install puppeteer and the problems seems to come from this personal install

Stack trace

TypeError: Cannot assign to read only property 'constructor' of object 'Error' at Object.createErrorClass (/usr/local/lib/node_modules/puppeteer/node_modules/puppeteer-core/lib/cjs/third_party/rxjs/rxjs.js:238:38) at ../../node_modules/rxjs/dist/cjs/internal/util/UnsubscriptionError.js (/usr/local/lib/node_modules/puppeteer/node_modules/puppeteer-core/lib/cjs/third_party/rxjs/rxjs.js:252:55) at __require (/usr/local/lib/node_modules/puppeteer/node_modules/puppeteer-core/lib/cjs/third_party/rxjs/rxjs.js:209:50) at ../../node_modules/rxjs/dist/cjs/internal/Subscription.js (/usr/local/lib/node_modules/puppeteer/node_modules/puppeteer-core/lib/cjs/third_party/rxjs/rxjs.js:321:33) at __require (/usr/local/lib/node_modules/puppeteer/node_modules/puppeteer-core/lib/cjs/third_party/rxjs/rxjs.js:209:50) at ../../node_modules/rxjs/dist/cjs/internal/Subscriber.js (/usr/local/lib/node_modules/puppeteer/node_modules/puppeteer-core/lib/cjs/third_party/rxjs/rxjs.js:649:26) at __require (/usr/local/lib/node_modules/puppeteer/node_modules/puppeteer-core/lib/cjs/third_party/rxjs/rxjs.js:209:50) at ../../node_modules/rxjs/dist/cjs/internal/Observable.js (/usr/local/lib/node_modules/puppeteer/node_modules/puppeteer-core/lib/cjs/third_party/rxjs/rxjs.js:887:24) at __require (/usr/local/lib/node_modules/puppeteer/node_modules/puppeteer-core/lib/cjs/third_party/rxjs/rxjs.js:209:50) at ../../node_modules/rxjs/dist/cjs/index.js (/usr/local/lib/node_modules/puppeteer/node_modules/puppeteer-core/lib/cjs/third_party/rxjs/rxjs.js:8919:24)

When I remove env var N8N_RUNNERS_ENABLED=true my workflow works fine.

Information on your n8n setup

  • **n8n version:**1.83.2
  • **Database (default: SQLite):**Postgres
  • **n8n EXECUTIONS_PROCESS setting (default: own, main):**default
  • **Running n8n via (Docker, npm, n8n cloud, desktop app):**Docker
  • **Operating system:**Redhat

I found a related topic but the problem seems to be solved with 1.83.0 but I use 1.83.2 and I still have the issue

@netroy,

Could you have a look please ? Seems the same than the issue fix by PR fix(core): Pass `NODE_PATH` to task runners by netroy · Pull Request #13652 · n8n-io/n8n · GitHub but for puppeteer I still have the issue

  1. Can you please share a simple workflow to reproduce this issue? That would hopefully speed up the fix, if we can reproduce this.
  2. Please don’t summon people like this in posts. There is a long queue of unanswered questions here, and we are also busy with plenty of other tasks. Summoning people like this is a bit like asking to skip the queue, which IMO is unfair to everyone else here. If you need priority support, it might make a lot more sense to contact the support team at [email protected]
2 Likes

Hello,

Noted I won’t do it again.

As you can see in WF just a require puppeteer trigger the error.

For the installation of puppeteer I have the following conf in Dockerfile :

RUN npm install -g [email protected]
ENV PUPPETEER_SKIP_CHROMIUM_DOWNLOAD true
ENV PUPPETEER_EXECUTABLE_PATH /usr/bin/chromium-browser
WORKDIR /src
RUN apk upgrade && apk update && apk add --no-cache --virtual
.build-deps
udev
ttf-opensans
chromium
ca-certificates
RUN cd /usr/local/lib/node_modules/n8n && npm install -g puppeteer

Thank for you help.

I have a very similar problem when running puppeteer in a task runner, but in my case require(‘puppeteer’) works and the fail occurs on puppeteer.launch(). The code with complete scraping process works with task runners disabled.
Bellow are some images with details about the code and error.


It should be fixed in next version but you should add this env var yo make it work

N8N_RUNNERS_ALLOW_PROTOTYPE_MUTATION=true

@Kent1 I’ve added the env and i’m currently on 1.89.2. I’ve successfully installed other packages like remeda but i’m getting the following with cctx. Do you think the next version will cover this?

Yes it should fix this !

1 Like

I tried, but still not working. Lets wait for the next version and see if this problem will be solved. My worry is ‘N8N_RUNNERS_ENABLED=true’ become default before this problem beeing solved.

This PR (not released in 1.89.2) fix the issue I could test it, and was a le to used puppeteer again.

Just wait this PR be used in futur version

@Kent1

I tried building from master and added the one extra line to install ts-kraken:

ARG NODE_VERSION=20
FROM n8nio/base:${NODE_VERSION}

ARG N8N_VERSION
RUN if [ -z "$N8N_VERSION" ] ; then echo "The N8N_VERSION argument is missing!" ; exit 1; fi

LABEL org.opencontainers.image.title="n8n"
LABEL org.opencontainers.image.description="Workflow Automation Tool"
LABEL org.opencontainers.image.source="https://github.com/n8n-io/n8n"
LABEL org.opencontainers.image.url="https://n8n.io"
LABEL org.opencontainers.image.version=${N8N_VERSION}

ENV N8N_VERSION=${N8N_VERSION}
ENV NODE_ENV=production
ENV N8N_RELEASE_TYPE=stable
RUN set -eux; \
	npm install -g --omit=dev n8n@${N8N_VERSION} --ignore-scripts && \
	npm rebuild --prefix=/usr/local/lib/node_modules/n8n sqlite3 && \
	rm -rf /usr/local/lib/node_modules/n8n/node_modules/@n8n/chat && \
	rm -rf /usr/local/lib/node_modules/n8n/node_modules/@n8n/design-system && \
	rm -rf /usr/local/lib/node_modules/n8n/node_modules/n8n-editor-ui/node_modules && \
	find /usr/local/lib/node_modules/n8n -type f -name "*.ts" -o -name "*.js.map" -o -name "*.vue" | xargs rm -f && \
	rm -rf /root/.npm

# Setup the Task Runner Launcher
ARG TARGETPLATFORM
ARG LAUNCHER_VERSION=1.1.1
COPY n8n-task-runners.json /etc/n8n-task-runners.json
# Download, verify, then extract the launcher binary
RUN \
	if [[ "$TARGETPLATFORM" = "linux/amd64" ]]; then export ARCH_NAME="amd64"; \
	elif [[ "$TARGETPLATFORM" = "linux/arm64" ]]; then export ARCH_NAME="arm64"; fi; \
	mkdir /launcher-temp && \
	cd /launcher-temp && \
	wget https://github.com/n8n-io/task-runner-launcher/releases/download/${LAUNCHER_VERSION}/task-runner-launcher-${LAUNCHER_VERSION}-linux-${ARCH_NAME}.tar.gz && \
	wget https://github.com/n8n-io/task-runner-launcher/releases/download/${LAUNCHER_VERSION}/task-runner-launcher-${LAUNCHER_VERSION}-linux-${ARCH_NAME}.tar.gz.sha256 && \
	# The .sha256 does not contain the filename --> Form the correct checksum file
	echo "$(cat task-runner-launcher-${LAUNCHER_VERSION}-linux-${ARCH_NAME}.tar.gz.sha256) task-runner-launcher-${LAUNCHER_VERSION}-linux-${ARCH_NAME}.tar.gz" > checksum.sha256 && \
	sha256sum -c checksum.sha256 && \
	tar xvf task-runner-launcher-${LAUNCHER_VERSION}-linux-${ARCH_NAME}.tar.gz --directory=/usr/local/bin && \
	cd - && \
	rm -r /launcher-temp

COPY docker-entrypoint.sh /

RUN \
	mkdir .n8n && \
	chown node:node .n8n
ENV SHELL /bin/sh

RUN npm install -g ts-kraken

USER node
ENTRYPOINT ["tini", "--", "/docker-entrypoint.sh"]

docker buildx build --platform linux/amd64 --build-arg N8N_VERSION=1.89.2 -t n8n:1.89.2-andy .

docker tag n8n:1.89.2-andy registry.digitalocean.com/platform-5-ecr/n8n:0.1.8

docker push registry.digitalocean.com/platform-5-ecr/n8n:0.1.8

i have this as well:

# n8n-values.yaml
imagePullSecret: "platform-5-ecr"
image:
  repository: "registry.digitalocean.com/platform-5-ecr/n8n"
  tag: "0.1.8"
resources:
  requests:
    memory: "1Gi"
  limits:
    memory: "2Gi"
n8n:
  extraEnv:
    - name: NODE_FUNCTION_ALLOW_BUILTIN
      value: "*"
    - name: NODE_FUNCTION_ALLOW_EXTERNAL
      value: "*"
    - name: N8N_RUNNERS_ALLOW_PROTOTYPE_MUTATION
      value: "true"

and can confirm that prior to adding NODE_FUNCTION_ALLOW_BUILTIN I was unable to use crypto after which it works. So my env vars are making it to the env presumably.

here is my issue

working:

not working:

Any help would be awesome. Thanks in advance :smiley:

It should be fix in 1.90.0

1 Like

Did you test the last version ?

Awesome thank you.

And no just the master branch from a couple days ago with my one change to add the nodejs module

i can confirm that it works now @Kent1 :smiley:

1 Like

Can you tell me if it’s still working for you in version 1.95.3 or higher ? I have issue with puppeteer and try to see if it’s only from my side or not

Thanks for your help