{"record":{"id":"b6c82ed49f86205f","repo":"FuelLabs/fuels-ts","slug":"chain-info-cache-empty","errorCode":"CHAIN_INFO_CACHE_EMPTY","errorMessage":"Provider chain info cache is empty. Please make sure to initialize the `Provider` properly by running `new Provider()`","messagePattern":"Provider chain info cache is empty\\. Please make sure to initialize the `Provider` properly by running `new Provider\\(\\)`","errorType":"exception","errorClass":"FuelError","httpStatus":null,"severity":"error","filePath":"packages/script/src/script-invocation-scope.ts","lineNumber":28,"sourceCode":"  TReturn = any,\n> extends FunctionInvocationScope<TArgs, TReturn> {\n  scriptRequest!: ScriptRequest<TArgs, TReturn>;\n\n  protected override async updateScriptRequest() {\n    if (!this.scriptRequest) {\n      await this.buildScriptRequest();\n    }\n\n    this.transactionRequest.setScript(this.scriptRequest, this.args);\n  }\n\n  private async buildScriptRequest() {\n    const programBytes = (this.program as AbstractScript).bytes;\n    const chainInfoCache = await (this.program.provider as Provider).getChain();\n\n    // TODO: Remove this error since it is already handled on Provider class\n    if (!chainInfoCache) {\n      throw new FuelError(\n        FuelError.CODES.CHAIN_INFO_CACHE_EMPTY,\n        'Provider chain info cache is empty. Please make sure to initialize the `Provider` properly by running `new Provider()`'\n      );\n    }\n\n    this.scriptRequest = new ScriptRequest(\n      programBytes,\n      (args: TArgs) => this.func.encodeArguments(args),\n      () => [] as unknown as TReturn\n    );\n  }\n}\n","sourceCodeStart":10,"sourceCodeEnd":41,"githubUrl":"https://github.com/FuelLabs/fuels-ts/blob/b3f37c91aca4aa9d5e4c0d3967f66237190826ea/packages/script/src/script-invocation-scope.ts#L10-L41","documentation":"Thrown by ScriptInvocationScope.buildScriptRequest() when provider.getChain() returns a falsy chain info cache. In practice this is effectively dead code: getChain() internally calls init() which fetches and populates Provider.chainInfoCache, and the source carries a TODO to remove this check because the Provider already guards it. It would only fire for a hand-rolled/mock Provider whose getChain() returns undefined, or if fetchChainAndNodeInfo() silently failed to populate the cache.","triggerScenarios":"Calling script functions on a Script bound to a mock Provider whose getChain() resolves to undefined; a Provider whose init()/fetchChainAndNodeInfo failed without throwing; an incompletely faked Provider in tests.","commonSituations":"Unit tests stubbing Provider.getChain to return undefined; a Provider constructed against an unreachable node whose chain fetch silently returned nothing (usually a different error is thrown first).","solutions":["Construct a real Provider with a reachable node URL: const provider = await Provider.create(url) (or new Provider(url) then await provider.init()).","In tests, mock getChain() to return a valid ChainInfo object (chainInfoCache populated) rather than undefined.","Confirm network connectivity to the node before instantiating the Script."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Ensure the Provider is initialized against a reachable node before binding a Script.\nconst provider = await Provider.create(nodeUrl); // or new Provider(nodeUrl) then await provider.init();\nif (!(await provider.getChain())) {\n  throw new Error('Provider chain info unavailable; check node URL and connectivity.');\n}","typeGuard":null,"tryCatchPattern":"try {\n  await script.functions.main().call();\n} catch (e) {\n  if (e instanceof FuelError && e.code === FuelError.CODES.CHAIN_INFO_CACHE_EMPTY) {\n    // re-init the provider / verify node reachability, then retry\n    await provider.init();\n  } else throw e;\n}","preventionTips":["Use Provider.create(url) (or call provider.init()) before passing the provider to a Script.","In tests, mock getChain() to return a valid ChainInfo, not undefined.","Confirm the node URL is reachable before instantiating SDK objects."],"tags":["provider","chain-info","initialization","script","typescript"],"backgroundTag":null,"analyzedSha":"b3f37c91aca4aa9d5e4c0d3967f66237190826ea","analyzedAt":"2026-08-12T20:30:56.448Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}