sveltejs / sveltejs/kit

Server listen hook

Open
#16,979 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
20.8k
Forks
2.3k
Avg merge
1d 16h
Merged PRs (30d)
156

Description

Describe the problem

I want to register webhooks on application start, but the webhook creation request requires response to a PING request. The init hook fires before http server start (adapter-node), so sveltekit can not answer the request yet and the webhook creation fails.

Describe the proposed solution

I would like to see a listen hook (hook.server.js) that fires as soon as SvelteKit is ready to receive requests.

Alternatives considered

I am currently using the init hook with a setTimeout.

Importance

would make my life easier

Additional Information

Not sure how this would work on serverless / edge platforms, but I think this would be very useful on standalone runtimes.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing the existing init hook in hook.server.js and the adapter-node server-start path. Determine where SvelteKit is ready to receive requests, then assess how a listen hook should behave on standalone runtimes versus serverless or edge platforms. Done means the hook fires at the requested readiness point without relying on setTimeout.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
backend
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
50/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.