`FileHandle.metadata` is annotated to return a file handle, but returns the `Metadata`
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 3/5
- Tiempo estimado
- 1-2 días
- Aptitud para principiantes
- 64/100
- Tipo de issue
- Error
- Claridad
- Bien especificado
- Estado de actividad
- Activo
- Stack tecnológico
- javascript, node.js
- Área
- backend, operating-systems
Línea de trabajo
Start with the FileHandle.metadata annotation and the _FileSystem_fstat kernel path, using the linked reproduction as the baseline. Run the provided gren make examples, then verify that metadata exposes FileSystem.Metadata fields and that the read example no longer accepts an incompatible handle or crashes.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Found against: gren 0.6.6, gren-lang/core 7.4.2, gren-lang/node 6.1.3, node 22
Reproduction: https://github.com/gilramir/gren-bug-reports/tree/main/2026-09-14-filehandle-metadata-type
FileSystem.FileHandle.metadata is annotated
metadata : ReadableFileHandle a -> Task FileSystem.Error (ReadableFileHandle FileSystem.Metadata)
but its kernel code, _FileSystem_fstat, succeeds with the Metadata record
itself. So reading a field of the result, the one thing metadata is for, does
not compile, and passing the result to FileHandle.read, which does compile,
crashes the program instead of failing the task.
Reproduction
gren.json dependencies: gren-lang/core 7.4.2, gren-lang/node 6.1.3. Save as src/Main.gren, which reads the size of gren.json through a file handle. Build with gren make Main --output=app:
module Main exposing (main)
import FileSystem
import FileSystem.FileHandle as FileHandle
import FileSystem.Path as Path
import Init
import Node
import Stream
import Task
main : Node.SimpleProgram a
main =
Node.defineSimpleProgram <| \env ->
Init.await FileSystem.initialize <| \fs ->
Node.endSimpleProgram
(FileHandle.openForRead fs (Path.fromPosixString "gren.json")
|> Task.andThen FileHandle.metadata
|> Task.map (\m -> "byteSize = " ++ String.fromInt m.byteSize)
|> Task.onError (\e -> Task.succeed (FileSystem.errorToString e))
|> Task.andThen (\line -> Stream.writeLineAsBytes line env.stdout)
|> Task.onError (\_ -> Task.succeed env.stdout)
)
Output:
$ gren make Main --output=app
Compiling ...-- TYPE MISMATCH ------------------------------------------------- src/Main.gren
This function cannot handle the argument sent through the (|>) pipe:
17| (FileHandle.openForRead fs (Path.fromPosixString "gren.json")
18| |> Task.andThen FileHandle.metadata
19| |> Task.map (\m -> "byteSize = " ++ String.fromInt m.byteSize)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
The argument is:
Task.Task
FileSystem.Error
(FileHandle.ReadableFileHandle FileSystem.Metadata)
But (|>) is piping it to a function that expects:
Task.Task FileSystem.Error { a | byteSize : Int }
Detected problems in 1 module.
src/ReadFromMetadata.gren is the same program with Task.map (\m -> ...)
replaced by what the annotation allows:
|> Task.andThen FileHandle.read
|> Task.map (\_ -> "read from the metadata")
It compiles, and crashes:
$ gren make ReadFromMetadata --output=app && node app
node:internal/errors:540
throw error;
^
TypeError [ERR_INVALID_ARG_TYPE]: The "fd" argument must be of type number. Received undefined
at Object.read (node:fs:604:8)
at _FileSystem_readHelper (/path/to/app:3260:6)
at Object.b (/path/to/app:3239:5)
at _Scheduler_step (/path/to/app:298:25)
at _Scheduler_enqueue (/path/to/app:279:7)
at /path/to/app:300:9
at /path/to/app:3484:9
at FSReqCallback.oncomplete (node:fs:197:5) {
code: 'ERR_INVALID_ARG_TYPE'
}
Node.js v22.23.2
- Lenguaje dominante
- JavaScript
- Estrellas
- 13
- Forks
- 6
- Merge medio
- 4 d 10 h
- PR fusionados (30 d)
- 4
Preparar el entorno
Este proyecto no incluye contenedor de desarrollo, Dockerfile ni guía de contribución, así que la configuración corre por tu cuenta: empieza por su README y consulta nuestra guía para la primera contribución para los pasos generales.
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de gren-lang/node
-
`ChildProcess.spawn` with `NoShell` looks for a program named after the program and its argumentsAbiertobug
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
-
bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
-
bug
Dificultad 3/5 1-2 días Aptitud para principiantes 74/100
-
enhancement
Dificultad 4/5 3-5 días Aptitud para principiantes 48/100
-
Sqlite: Bytes encoder/decoderAbiertoenhancement
Dificultad 4/5 3-5 días Aptitud para principiantes 48/100
Todos los issues de gren-lang/node
Issues similares
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 74/100
solana-foundation/solana-com#2202 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 1/5 Menos de una hora Aptitud para principiantes 92/100
yegor256/copyrights-action#216 ·
-
[BUG] onScroll never refreshes the window container's height after a vertical-only viewport resizeAbierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 88/100
juliangarnier/anime#1192 ·
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 84/100
PedestrianDynamics/pyFDS-Evac#226 ·
Los mantenedores suelen responder en 1 día