Render Tutorials
Stock research: from flaky to reliable

Wire the task entrypoint

⏱ 5 min

A second Render service will run your tasks. It runs separately from your Express app. On boot it must load every file that calls task() so Render knows which jobs exist.

Create that service on Render in the next deploy step.

Why a separate file?

Baseline already has server/src/index.ts: Express, /api/research, SSE. That runs on the web service only.

tasks/src/ has no index.ts yet: search, research, and synthesis are library code the web server imports directly.

The second service runs npm run start from the tasks/ folder. It imports task modules through its own entry file. You add tasks/src/index.ts for that. It shares a filename with the web entry, but it is a separate entrypoint in a separate folder and service. The research pipeline entry remains research.ts on the web side.

That file can stay one line while you only have searchOne. When you add more tasks later, add one import per task file here.

Create tasks/src/index.ts

tasks/src/index.ts
import './search.js'

The .js extension is required for Node ESM after tsc. Importing search.ts runs the task({ name: 'searchOne', … }) registration side effect.

Add start script

In tasks/package.json, under "scripts":

tasks/package.json
"start": "node dist/tasks/src/index.js"

With "rootDir": "..", compiled output path is dist/tasks/src/index.js.

On Render, Start Command will be npm run start.

Optional local smoke

Terminal
$cd tasks && npm run build && npm run start
Task runner listening...

Process should stay up. Ctrl+C to stop. Real task runs happen on Render after you create the second service.

Commit search.ts, index.ts, package.json, and lockfile. Push before deploy steps.

What you learned

  • tasks/src/index.ts is the task-service entrypoint; server/src/index.ts stays the web entrypoint
  • The file imports search.js so task() registration runs when that service starts
  • start script points at dist/tasks/src/index.js