Skip to content

Propagate future panics on dereference - #144

Open
corkine wants to merge 1 commit into
glojurelang:mainfrom
corkine:upstream/future-panic-on-deref
Open

corkine wants to merge 1 commit into
glojurelang:mainfrom
corkine:upstream/future-panic-on-deref

Conversation

@corkine

@corkine corkine commented Nov 21, 2026

Copy link
Copy Markdown

Related to #40.

Currently a panic while evaluating a future escapes its worker goroutine and terminates the process, even if the caller wraps @future in a matching try/catch. For example:

(try
  @(future (throw (ex-info "future failed" {:result :caught})))
  (catch Exception e (:result (ex-data e))))

This patch saves the original panic value in the future and rethrows it when the completed future is dereferenced. The caller can then catch it just as it can catch a synchronous failure. A timed dereference still returns its timeout value if the deadline wins. With no matching handler on dereference, the CLI still exits nonzero through its normal error handling.

The deliberate behavior change is that a failed future that is never dereferenced no longer terminates the process on its own.

Validation on Linux: the full pkg/lang and pkg/runtime tests passed; focused future regressions also passed with glj_aot_runtime. The CLI caught case now continues, and the uncaught case exits 1 and reports the error at dereference.

Recover in the future worker and rethrow the original panic value when the caller reads the completed future. Add subprocess coverage for catchable exceptions and preserve timeout behavior.
@corkine
corkine requested a review from jfhamlin as a code owner November 21, 2026 00:55

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant