fix(loader-server): a broken or looping symlink in the build folder crashes startup

Aberta
#146 0 comentários 0 reações 0 responsáveis Ver no GitHub

Mantenedores costumam responder em até 1 dia

Ninguém assumiu esta issue ainda.

Avaliação

Dificuldade
3/5
Tempo estimado
1-2 dias
Facilidade para iniciantes
68/100
Tipo de issue
Bug
Clareza
Claramente especificada
Status de atividade
Ativa
Stack de tecnologia
bun, typescript
Domínio
backend, security

Direção de pesquisa

Read apps/server/src/files.ts and apps/client/src/files.ts, starting with the getFiles and addPath functions cited in the report. Check how each handles symlinks, filesystem errors, and paths that resolve outside the build folder. Done means broken or cyclic links no longer crash startup or recurse indefinitely, and files outside the build folder are not listed or served.

Escrita pelo modelo de indexação a partir do texto da issue.

Descrição

app:client app:server bug
Which app is this bug report for?

server

Issue description

Also affects client.

getFiles uses statSync, which follows symlinks, and catches nothing:

  • a dangling link throws ENOENT and the server loader dies at startup;
  • a link to a parent folder recurses until the stack overflows.

The client's addPath catches errors per entry but loops the same way on cyclic links. A symlink inside the build folder that points outside it is also served, because resolveInside only checks the path as a string.

Found by reading the code path (not reproduced).

Expected: symlinks don't crash the loader, and only files inside the build folder are listed and served.

Suggested fix: use lstat and skip symlinks (or resolve them with realpath and keep only targets inside the root), and catch errors per entry.

Found during a read-only audit of main @ 044c766 (2026-11-11).

Code sample
const addPath = (path: string, exportedPath: string) => {
  if (fs.statSync(path).isDirectory()) { // follows symlinks, throws on dangling ones
    for (const file of fs.readdirSync(path)) addPath(join(path, file), join(exportedPath, file));
    return;
  }
  paths.push([`/${exportedPath}`, path]);
};
Versions
  • @nanoforge-dev/loader-client / @nanoforge-dev/loader-server / @nanoforge-dev/loader-website 1.7.0 (main @ 044c766)
  • Bun 1.3.14
  • Linux x86_64
Issue priority

Low (slightly annoying)

I have tested this issue on a development release

044c766

Linguagem predominante
TypeScript
Estrelas
1
Forks
0
Merge médio
17h 25min
PRs com merge (30d)
11

Preparar o ambiente

Primeiros passos

  1. Leia a issue inteira e depois o guia de contribuição do projeto.
  2. Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
  3. Faça um fork do repositório e trabalhe em uma branch.
  4. Abra um pull request que referencie o número da issue.

Mais de NanoForge-dev/Loader

Todas as issues de NanoForge-dev/Loader

Issues semelhantes

Mais issues de TypeScript

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.