{"record":{"id":"2cb17f6fd824cd71","repo":"petkaantonov/bluebird","slug":"cannot-get-fulfillment-value-of-a-non-fulfilled-pr","errorCode":null,"errorMessage":"cannot get fulfillment value of a non-fulfilled promise\n\n    See http://goo.gl/MqrFmX\n","messagePattern":"cannot get fulfillment value of a non-fulfilled promise\n\n    See http://goo\\.gl/MqrFmX\n","errorType":"validation","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"src/synchronous_inspection.js","lineNumber":22,"sourceCode":"    if (promise !== undefined) {\n        promise = promise._target();\n        this._bitField = promise._bitField;\n        this._settledValueField = promise._isFateSealed()\n            ? promise._settledValue() : undefined;\n    }\n    else {\n        this._bitField = 0;\n        this._settledValueField = undefined;\n    }\n}\n\nPromiseInspection.prototype._settledValue = function() {\n    return this._settledValueField;\n};\n\nvar value = PromiseInspection.prototype.value = function () {\n    if (!this.isFulfilled()) {\n        throw new TypeError(INSPECTION_VALUE_ERROR);\n    }\n    return this._settledValue();\n};\n\nvar reason = PromiseInspection.prototype.error =\nPromiseInspection.prototype.reason = function () {\n    if (!this.isRejected()) {\n        throw new TypeError(INSPECTION_REASON_ERROR);\n    }\n    return this._settledValue();\n};\n\nvar isFulfilled = PromiseInspection.prototype.isFulfilled = function() {\n    return (this._bitField & IS_FULFILLED) !== 0;\n};\n\nvar isRejected = PromiseInspection.prototype.isRejected = function () {\n    return (this._bitField & IS_REJECTED) !== 0;","sourceCodeStart":4,"sourceCodeEnd":40,"githubUrl":"https://github.com/petkaantonov/bluebird/blob/c220cfe480868e2f5c5de4fe8bb3b04b97588d7f/src/synchronous_inspection.js#L4-L40","documentation":"The synchronous inspection API's `.value()` (src/synchronous_inspection.js:22) returns the fulfillment value only if the underlying promise is fulfilled. Calling it on a pending or rejected PromiseInspection throws this TypeError. Use `.isFulfilled()` first.","triggerScenarios":"`promise.reflect().then(insp => insp.value())` when the original promise rejected; `Promise.inspect(promise)` on a still-pending promise then calling `.value()` before settlement.","commonSituations":"reflect-based error aggregation where code reads `.value()` without branching on `isFulfilled()`; race-inspection patterns that assume fulfillment.","solutions":["Check `insp.isFulfilled()` before calling `.value()`; use `insp.reason()` otherwise.","Use `insp.isRejected()` / `insp.isPending()` for explicit branching.","In reflect-aggregation code, map each inspection to `{state, value|reason}`."],"exampleFix":"// before\np.reflect().then(insp => console.log(insp.value()));\n// after\np.reflect().then(insp => {\n  if (insp.isFulfilled()) console.log(insp.value());\n  else console.error(insp.reason());\n});","handlingStrategy":"type-guard","validationCode":"const readValue = (insp) => {\n  if (!insp.isFulfilled()) throw new TypeError('value() requires a fulfilled inspection');\n  return insp.value();\n};","typeGuard":"const readIfFulfilled = (insp) => insp.isFulfilled() ? { ok: true, value: insp.value() } : { ok: false, reason: insp.isRejected() ? insp.reason() : null };","tryCatchPattern":"p.reflect().then(insp => {\n  let out;\n  try { out = insp.value(); } catch (e) {\n    out = insp.isRejected() ? insp.reason() : null;\n  }\n  return out;\n});","preventionTips":["Always gate .value() behind isFulfilled().","In reflect() aggregation, branch on isFulfilled/isRejected before reading.","Remember pending inspections support neither value() nor reason()."],"tags":["typeerror","reflect","synchronous-inspection"],"backgroundTag":"promise-inspection-wrong-state","analyzedSha":"c220cfe480868e2f5c5de4fe8bb3b04b97588d7f","analyzedAt":"2026-09-02T02:30:20.863Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T06:17:21.866Z"}