diff --git a/collects/racket/promise.rkt b/collects/racket/promise.rkt index 4a96840f2b..3015ff30f3 100644 --- a/collects/racket/promise.rkt +++ b/collects/racket/promise.rkt @@ -98,9 +98,13 @@ (lambda (p) (reify-result (let ([v (pref p)]) (if (running-thread? v) - (begin (thread-wait (running-thread-thread v)) - (pref p)) - v)))) + (let ([t (running-thread-thread v)]) + (thread-wait t) + (let ([v (pref p)]) + (if (running-thread? v) + (error 'force "promise's thread terminated without result or exception\n promise: ~e" p) + v))) + v)))) #:property prop:evt (lambda (p) (let ([v (pref p)]) diff --git a/collects/scribblings/reference/promise.scrbl b/collects/scribblings/reference/promise.scrbl index dcd03c80a2..527efc4326 100644 --- a/collects/scribblings/reference/promise.scrbl +++ b/collects/scribblings/reference/promise.scrbl @@ -111,7 +111,10 @@ group} specified by @racket[thread-group-expr], which defaults to appear at most once. Exceptions raised by the @racket[body]s are caught as usual and raised -only when the promise is @racket[force]d.} +only when the promise is @racket[force]d. Unlike @racket[delay/sync], +if the thread running @racket[body] terminates without producing a result +or exception, @racket[force] of the promise raises an exception (instead +of blocking).} @defform/subs[(delay/idle body/option ...+) ([body/option body