GopeedLab/gopeed · error
promise rejected
Error message
promise rejected
What it means
exportJSError in the stream module (pkg/download/engine/inject/stream/module.go:537-539) is the same conversion helper as the engine's: a promise rejection value of undefined/null, or a nil goja.Value, cannot yield a message, so the error degrades to the generic 'promise rejected'. Any Error object, string, or exported error would have produced a specific message instead.
Source
Thrown at pkg/download/engine/inject/stream/module.go:539
})
if _, err := thenFn(value, onFulfilled, onRejected); err != nil {
send(nil, err)
}
return
}
}
send(value, nil)
})
if !ok {
return nil, errors.New("engine loop terminated")
}
res := <-ch
return res.value, res.err
}
func exportJSError(value goja.Value) error {
if value == nil || goja.IsUndefined(value) || goja.IsNull(value) {
return errors.New("promise rejected")
}
if err, ok := value.Export().(error); ok {
return err
}
stack := value.String()
if ro, ok := value.(*goja.Object); ok {
stackVal := ro.Get("stack")
if stackVal != nil && stackVal.String() != "" {
stack = stackVal.String()
}
}
return errors.New(stack)
}
type fetchRegistry struct {
mu sync.Mutex
streams map[string]*fetchStream
ctx context.ContextView on GitHub (pinned to 7b7327ffb3)
Solutions
- Instrument the script: wrap stream calls with .catch(e => { throw (e === undefined ? new Error('stream rejected without reason') : e })
- Fix scripts to reject with Error objects: reject(new Error('stream aborted'))
- Enable any script-side logging the engine provides to capture the failure site
- Address the root cause once a real message is recoverable
Example fix
// before (script)
stream.open(u).then(null, () => reject())
// after (script)
stream.open(u).then(null, (e) => reject(e instanceof Error ? e : new Error('stream open failed: ' + String(e)))) Defensive patterns
Strategy: try-catch
Validate before calling
// Script-side: normalize rejections before they cross into Go
// .catch(e => { throw e == null ? new Error('stream rejected without reason') : e }) Type guard
// Script-side guard:
function norm(e) { return e == null ? new Error('rejected without reason') : e } Try / catch
if err != nil && err.Error() == "promise rejected" {
// stream rejection had no reason value: add script-side catch logging to find the cause
} Prevention
- Reject with Error objects in all stream script code
- Wrap polyfill rejections so undefined becomes a descriptive Error
- Treat the bare message as a diagnostics gap, not a root cause
When it happens
Trigger: Stream-related script code rejects with no argument (reject()) or throws undefined/null (common in minified bundles); a fetch/stream polyfill signaling failure with reject(undefined); rejection callbacks invoked with zero arguments.
Common situations: Third-party resolver scripts with bare undefined throws; debugging dead-ends because the message carries no cause — it strictly means 'rejected without a reason value'.
Related errors
AI-assisted analysis of GopeedLab/gopeed@7b7327ffb3 (2026-08-16).
Data as JSON: /api/errors/837c7ec5fdacc597.
Report an issue: GitHub.