sveltejs / sveltejs/kit

Add `SOCKET_MODE`, `SOCKET_USER` and `SOCKET_GROUP` in addition to `SOCKET_PATH` to adapter-node

Open
#14,488 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

Describe the problem

I'm struggling with sharing sveltekit app's socket with a web server.

Describe the proposed solution

Most daemons nowadays allow you to customize socket permissions and ownership via flags. Add SOCKET_MODE, SOCKET_USER and SOCKET_GROUP environment variables

Alternatives considered

One way would be to add web server to the app's linux group but that way the web server will be able to read more than just the socket.

Importance

would make my life easier

Additional Information

Looks like adapter-node uses polka to serve http requests.

https://github.com/sveltejs/kit/blob/0afc71d936821b45ed4987b9bb7c7af9e826c3a9/packages/adapter-node/src/index.js#L41

Which uses nodejs's http server.listen function which accepts the path to unix socket to create it

https://nodejs.org/docs/v22.19.0/api/net.html#serverlistenoptions-callback

I couldn't find any info on how to change permission/ownership for it. I did try to change ownership and permissions manually after starting the app but it keeps resetting it.

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 in packages/adapter-node/src/index.js around the referenced server.listen call, then read Node.js net.Server.listen options documentation. Trace how SOCKET_PATH is handled and determine how the three requested environment variables should map to Unix socket permissions and ownership. Done means adapter-node supports the variables without regressing existing socket behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, node.js
Domain
backend
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
52/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.