{"record":{"id":"78d618249ba6888e","repo":"remix-run/remix","slug":"err-invalid-return-value","errorCode":"ERR_INVALID_RETURN_VALUE","errorMessage":"Expected instance of Promise to be returned from the \"promiseFn\" function but got type ${typeof promise} (${stringify(promise)}).","messagePattern":"Expected instance of Promise to be returned from the \"promiseFn\" function but got type (.+?) \\((.+?)\\)\\.","errorType":"validation","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"packages/assert/src/lib/assert.ts","lineNumber":614,"sourceCode":"          actual: e,\n          expected: expectedError,\n          operator: 'doesNotThrow',\n          generatedMessage: false,\n        },\n        false,\n      )\n    }\n\n    throw e\n  }\n}\n\nfunction getPromise(value: (() => Promise<unknown>) | Promise<unknown>): Promise<unknown> {\n  if (typeof value === 'function') {\n    let promise = value()\n\n    if (!(promise instanceof Promise)) {\n      throw createNodeTypeError(\n        'ERR_INVALID_RETURN_VALUE',\n        `Expected instance of Promise to be returned from the \"promiseFn\" function but got type ${typeof promise} (${stringify(\n          promise,\n        )}).`,\n      )\n    }\n\n    return promise\n  }\n\n  if (!(value instanceof Promise)) {\n    throw createInvalidArgumentTypeError(\n      'promiseFn',\n      'of type function or an instance of Promise',\n      value,\n    )\n  }\n","sourceCodeStart":596,"sourceCodeEnd":632,"githubUrl":"https://github.com/remix-run/remix/blob/9696913134be3a4423513d2775f7b31d6917c049/packages/assert/src/lib/assert.ts#L596-L632","documentation":"When assert.promise() receives a function, it calls it and requires the return value to be a genuine Promise instance. If the function returns a thenable-less value (or a custom thenable that isn't a Promise), it throws ERR_INVALID_RETURN_VALUE.","triggerScenarios":"assert.throws-like usage where promiseFn returns undefined, a plain value, or an object with a .then that is not a native Promise.","commonSituations":"Async functions transpiled/monkey-patched to return non-native thenables in test environments, or forgetting to return the promise inside the function.","solutions":["Ensure the function returns a native Promise (async functions or Promise.resolve(...))","Await or wrap third-party thenables: Promise.resolve(thenable)"],"exampleFix":"// before\nassert.promise(() => fetchLater()) // returns undefined\n// after\nassert.promise(() => Promise.resolve(fetchLater()))","handlingStrategy":"type-guard","validationCode":"let result = promiseFn()\nif (!(result instanceof Promise)) result = Promise.resolve(result)","typeGuard":"const returnsNativePromise = (fn: () => unknown): fn is () => Promise<unknown> =>\n  fn() instanceof Promise","tryCatchPattern":null,"preventionTips":["Always return the promise from the function passed to assert.promise"],"tags":["assert","promise","invalid-return"],"backgroundTag":"non-promise-returned-from-async","analyzedSha":"9696913134be3a4423513d2775f7b31d6917c049","analyzedAt":"2026-08-27T19:55:01.024Z","schemaVersion":2},"datasetVersion":"2026-08-28T00:17:15.603Z"}