Summary
The two core interfaces don't accept a context.Context:
platform/script/compiler.go:17-29 — Compile(scriptReader io.ReadCloser)
platform/script/loader/loader.go:9-12 — GetReader() (io.ReadCloser, error)
This causes three concrete problems today:
-
The Extism compiler stores ctx on the struct via a WithContext option (engines/extism/compiler/compiler.go:17, engines/extism/compiler/options.go:96-104), which is racy if a Compiler is shared across goroutines.
-
The Risor inner compile hard-codes context.Background() (engines/risor/compiler/internal/compile/compile.go:21), so caller cancellation is ignored entirely.
-
HTTP compile can hang indefinitely because ExecutableUnit calls GetReader() (platform/script/executableUnit.go:61), not GetReaderWithContext. The HTTP loader has the context-aware variant but nothing reaches for it.
Proposal
Compile(ctx context.Context, r io.ReadCloser) (ExecutableContent, error)
GetReader(ctx context.Context) (io.ReadCloser, error) — drop the GetReaderWithContext helper as redundant.
- Delete
WithContext from the Extism compiler.
- Plumb the context through
NewExecutableUnit so the loader call gets the same one.
Files
platform/script/compiler.go
platform/script/loader/loader.go
platform/script/loader/{fromHTTP,fromBytes,fromString,fromIoReader,fromDisk}.go
platform/script/executableUnit.go
engines/{extism,risor,starlark}/compiler/compiler.go
engines/risor/compiler/internal/compile/compile.go
engines/extism/compiler/options.go (remove WithContext)
This is a breaking-change candidate for v1.
Summary
The two core interfaces don't accept a
context.Context:platform/script/compiler.go:17-29—Compile(scriptReader io.ReadCloser)platform/script/loader/loader.go:9-12—GetReader() (io.ReadCloser, error)This causes three concrete problems today:
The Extism compiler stores ctx on the struct via a
WithContextoption (engines/extism/compiler/compiler.go:17,engines/extism/compiler/options.go:96-104), which is racy if a Compiler is shared across goroutines.The Risor inner compile hard-codes
context.Background()(engines/risor/compiler/internal/compile/compile.go:21), so caller cancellation is ignored entirely.HTTP compile can hang indefinitely because
ExecutableUnitcallsGetReader()(platform/script/executableUnit.go:61), notGetReaderWithContext. The HTTP loader has the context-aware variant but nothing reaches for it.Proposal
Compile(ctx context.Context, r io.ReadCloser) (ExecutableContent, error)GetReader(ctx context.Context) (io.ReadCloser, error)— drop theGetReaderWithContexthelper as redundant.WithContextfrom the Extism compiler.NewExecutableUnitso the loader call gets the same one.Files
platform/script/compiler.goplatform/script/loader/loader.goplatform/script/loader/{fromHTTP,fromBytes,fromString,fromIoReader,fromDisk}.goplatform/script/executableUnit.goengines/{extism,risor,starlark}/compiler/compiler.goengines/risor/compiler/internal/compile/compile.goengines/extism/compiler/options.go(removeWithContext)This is a breaking-change candidate for v1.