cloudflare / cloudflare/workerd
DiskDirectory services don't resolve absolute `path`s against import paths
- Dominant language
- C++
- Stars
- 8.7k
- Forks
- 739
- Avg merge
- 2d 20h
- Merged PRs (30d)
- 174
Description
Reproduction steps:
1. Put this configuration in a file named `app.capnp`:
```
using Workerd = import "/workerd/workerd.capnp";
const config :Workerd.Config = (
sockets = [
(
name = "directory-viewer",
address = "*:8080",
http = (),
service = "dir"
),
],
services = [
(
name = "dir",
disk = (
path = "/assets"
)
)
]
);
```
2. In the same directory, `mkdir assets; workerd -I $(pwd) serve app.capnp`
The expectation is that startup succeeds and serves from the empty directory on 8080.
Instead:
```
λ tree
.
├── app.capnp
└── assets
2 directories, 1 file
λ workerd serve -I $(pwd) app.capnp
Directory named "dir" not found: /assets
```
The comment here indicates absolute paths should work:
https://github.com/cloudflare/workerd/blob/f0b6c864aac433a2ba958474d343aa3fc966798f/src/workerd/server/workerd.capnp#L763-L768
Because this doesn't work, I think workerd configurations containing DiskDirectory services can only ever be served from the single directory where the relative path in the configuration is correct, or by duplicatively passing the directory on the CLI with `-d`, like `workerd serve -ddir=/tmp/disk-test/assets /tmp/disk-test/app.capnp`.
Contributor guide
Assessment
This issue has not been assessed yet.