{"record":{"id":"939568c77ae3f8fb","repo":"FuelLabs/fuels-ts","slug":"invalid-provider","errorCode":"INVALID_PROVIDER","errorMessage":"Error initializing Fuel Connector","messagePattern":"Error initializing Fuel Connector","errorType":"exception","errorClass":"FuelError","httpStatus":null,"severity":"critical","filePath":"packages/account/src/connectors/fuel.ts","lineNumber":111,"sourceCode":"    this.setMaxListeners(1_000);\n    // Set all connectors\n    this._connectors = config.connectors ?? [];\n    // Set the target object to listen for global events\n    this._targetObject = this.getTargetObject(config.targetObject);\n    // Set default storage\n    this._storage = config.storage === undefined ? this.getStorage() : config.storage;\n    // Setup all methods\n    this.setupMethods();\n    this._initializationPromise = this.initialize();\n  }\n\n  private async initialize(): Promise<void> {\n    try {\n      const connectResponse = this.setDefaultConnector();\n      this._targetUnsubscribe = this.setupConnectorListener();\n      await connectResponse;\n    } catch (error) {\n      throw new FuelError(ErrorCode.INVALID_PROVIDER, 'Error initializing Fuel Connector');\n    }\n  }\n\n  public async init(): Promise<Fuel> {\n    await this._initializationPromise;\n    return this;\n  }\n\n  /**\n   * Return the target object to listen for global events.\n   */\n  private getTargetObject(targetObject?: TargetObject): TargetObject | null {\n    if (targetObject) {\n      return targetObject;\n    }\n    if (typeof window !== 'undefined') {\n      return window;\n    }","sourceCodeStart":93,"sourceCodeEnd":129,"githubUrl":"https://github.com/FuelLabs/fuels-ts/blob/b3f37c91aca4aa9d5e4c0d3967f66237190826ea/packages/account/src/connectors/fuel.ts#L93-L129","documentation":"Thrown by Fuel.initialize when either setDefaultConnector or setupConnectorListener throws during startup. The Fuel connector manager wraps the underlying failure in a single INVALID_PROVIDER error because the wallet-connector subsystem cannot operate without a healthy default connector and event wiring. It is a fatal init-time error: the connector manager is unusable until fixed.","triggerScenarios":"Constructing new Fuel({ connectors, storage, targetObject }) where setDefaultConnector throws (e.g. no connectors passed, storage inaccessible, or the chosen default connector fails to load), or setupConnectorListener throws because the target object (window/global event source) is missing or malformed.","commonSituations":"Running in an environment without the expected wallet-injection global (SSR, a frame without the extension), passing an empty connectors array, a corrupted storage entry for the saved connector name, or a version mismatch between the SDK and the injected connector.","solutions":["Pass at least one connector in config.connectors and ensure the runtime has the matching global event source the connector listens to.","Check that config.storage is a valid Storage-like object (or omit it to use the default) and that persisted connector state is not corrupt.","Wrap `await fuel.init()` in try/catch, log the inner error, and degrade to a non-connector flow when initialization fails in SSR/no-extension contexts."],"exampleFix":"// before\nconst fuel = new Fuel({ connectors: [myConnector] });\nawait fuel.init();\n\n// after\nconst fuel = new Fuel({ connectors: [myConnector], storage: localStorage });\ntry {\n  await fuel.init();\n} catch (e) {\n  if (e.code === ErrorCode.INVALID_PROVIDER) {\n    // fall back to direct provider/wallet flow\n  } else throw e;\n}","handlingStrategy":"try-catch","validationCode":"// Pre-flight: ensure at least one connector and a usable target object exist\nfunction canInitFuel(config: { connectors?: unknown[]; targetObject?: any }): boolean {\n  return (config.connectors?.length ?? 0) > 0;\n}","typeGuard":"function hasConnectors(config: { connectors?: FuelConnector[] }): config is { connectors: FuelConnector[] } {\n  return Array.isArray(config.connectors) && config.connectors.length > 0;\n}","tryCatchPattern":"try {\n  await fuel.init();\n} catch (e) {\n  if (e instanceof FuelError && e.code === ErrorCode.INVALID_PROVIDER) {\n    // log inner cause, fall back to a direct Provider/Wallet flow\n  } else throw e;\n}","preventionTips":["Pass at least one connector and a valid storage/targetObject in the Fuel config.","Wrap fuel.init() in try/catch in environments where the connector global may be absent (SSR, iframes).","Degrade to a non-connector flow when initialization fails rather than crashing."],"tags":["connector","initialization","fuel","ssr"],"backgroundTag":null,"analyzedSha":"b3f37c91aca4aa9d5e4c0d3967f66237190826ea","analyzedAt":"2026-08-12T20:30:56.448Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}