Render background worker starting twice

Hi, this issue has been posted about before like here (Application starting twice), but I have a background worker that on the first deploy is getting run twice (i.e. deploy succeeds, it calls the entry script, which is successful, and is long-lived, then after processing one event, it runs the whole startup command again

This is what my yaml file look likes

- name: name
      type: worker
      env: node
      plan: starter 
      branch: staging
      buildCommand: cd backend && npm install && npx prisma generate --schema=./packages/shared/prisma/schema.prisma && npx prisma migrate deploy --schema=./packages/shared/prisma/schema.prisma && npm run build:<name>
      startCommand: cd backend && npm run start:<name>

For a little more context, my background worker is a service which opens a websocket and listens for emitted events and weirdly, this second run only happens whenever the first event is picked up from the websocket and never after that.

any ideas what is going and how to fix it, happy to provide more context/info

This is as seen in the server logs
==> Deploying…

May 4 02:27:48 AM==> Docs on specifying a Node version: Setting Your Node.js Version | Render Docs

May 4 02:27:48 AM==> Using Bun version 1.1.0 (default)

May 4 02:27:48 AM==> Docs on specifying a bun version: Setting your Bun Version | Render Docs

May 4 02:27:49 AM==> Running ‘cd backend && npm run start:contract-indexer’

May 4 02:27:49 AM==> Your service is live :tada:

May 4 02:27:50 AM

May 4 02:27:50 AM> start:

May 4 02:27:50 AM> npm run start --workspace=packages/

May 4 02:27:50 AM

May 4 02:27:50 AM

May 4 02:27:50 AM> @1.0.0 start

May 4 02:27:50 AM> ts-node src/index.ts

May 4 02:27:50 AM

(these are my application logs)
May 4 02:28:01 AMConnected to Redis

May 4 02:28:02 AMContract subscription started.

May 4 02:29:29 AMLast synced…

May 4 02:29:36 AMConnected to Redis

May 4 02:29:43 AMProcessing …

May 4 02:29:44 AMProcessed …

(and here it’s deploying everything again)
May 4 02:29:45 AM==> Using Node version 18.18.0 via environment variable NODE_VERSION

May 4 02:29:45 AM==> Docs on specifying a Node version: Setting Your Node.js Version | Render Docs

May 4 02:29:45 AM==> Using Bun version 1.1.0 (default)

May 4 02:29:45 AM==> Docs on specifying a bun version: Setting your Bun Version | Render Docs

May 4 02:29:46 AM==> Running ‘cd backend && npm run start:’

May 4 02:29:47 AM

May 4 02:29:47 AM> start:

May 4 02:29:47 AM> npm run start --workspace=packages/

removed the package name but this is not an issue with package entrypoints if you’re wondering why the commands look cut off

hey,

Hmm, it’s hard to say with the limited information provided. If you’re still experiencing this issue, I recommend reaching out directly through the ‘Help’ button on the dashboard. That way, we can take a closer look at your service config and assist you more effectively.

Jérémy.
Render Support, UTC+3

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.