{"record":{"id":"a7bcdfb8c54dfabd","repo":"parcel-bundler/parcel","slug":"genericfailure-a7bcdf","errorCode":"GenericFailure","errorMessage":"resolveAsync does not support custom fs or module_dir_resolver","messagePattern":"resolveAsync does not support custom fs or module_dir_resolver","errorType":"exception","errorClass":"napi::Error","httpStatus":null,"severity":"error","filePath":"crates/node-bindings/src/resolver.rs","lineNumber":283,"sourceCode":"      resolve_internal(&self.resolver, self.mode, options)?;\n    resolve_result_to_js(env, res, invalidations, side_effects, module_type)\n  }\n\n  #[cfg(target_arch = \"wasm32\")]\n  #[napi]\n  pub fn resolve_async(&'static self) -> Result<JsObject> {\n    panic!(\"resolveAsync() is not supported in Wasm builds\")\n  }\n\n  #[cfg(not(target_arch = \"wasm32\"))]\n  #[napi]\n  pub fn resolve_async(&'static self, options: ResolveOptions, env: Env) -> Result<JsObject> {\n    let (deferred, promise) = env.create_deferred()?;\n    let resolver = &self.resolver;\n    let mode = self.mode;\n\n    if !self.supports_async || resolver.module_dir_resolver.is_some() {\n      return Err(napi::Error::new(\n        napi::Status::GenericFailure,\n        \"resolveAsync does not support custom fs or module_dir_resolver\",\n      ));\n    }\n\n    rayon::spawn(move || {\n      let (res, invalidations, side_effects, module_type) =\n        match resolve_internal(&resolver, mode, options) {\n          Ok(r) => r,\n          Err(e) => return deferred.reject(e),\n        };\n\n      deferred.resolve(move |env| {\n        resolve_result_to_js(env, res, invalidations, side_effects, module_type)\n      });\n    });\n\n    Ok(promise)","sourceCodeStart":265,"sourceCodeEnd":301,"githubUrl":"https://github.com/parcel-bundler/parcel/blob/59484858a1a0bcbb71f74088956bb437a2db6505/crates/node-bindings/src/resolver.rs#L265-L301","documentation":"Thrown by resolve_async when the Resolver was constructed with a custom fs or a module_dir_resolver. The async path uses rayon::spawn and only supports the OS filesystem (supports_async is set true only when no custom fs is supplied). The check is an explicit guard before spawning, so the error fires synchronously on the call, not inside the promise.","triggerScenarios":"Constructing a Resolver with options.fs (a custom JsFileSystemOptions) or options.moduleDirResolver (a function), then calling resolver.resolveAsync(opts). Either condition independently triggers the error. Using OsFileSystem (no fs option) with no module_dir_resolver allows async.","commonSituations":"Building a resolver over a virtual/remote filesystem and wanting non-blocking resolution; integrating a custom module directory resolver for monorepo setups and assuming it composes with async; copying a sync-configured Resolver into an async code path.","solutions":["Use the synchronous resolve() method instead of resolveAsync() when a custom fs or module_dir_resolver is required.","Drop the custom fs option (use the default OS filesystem) if you need async and can tolerate real-disk resolution.","Drop the moduleDirResolver option and handle module directory resolution in a wrapper around sync resolve.","If you need both custom fs and non-blocking behavior, run sync resolve() in a worker thread yourself."],"exampleFix":"// before\nconst resolver = new Resolver(root, { fs: customFs, mode: 1 });\nconst result = await resolver.resolveAsync(opts); // throws GenericFailure\n\n// after — use sync resolve, offload if you need non-blocking\nconst resolver = new Resolver(root, { fs: customFs, mode: 1 });\nconst result = resolver.resolve(opts); // synchronous, works with custom fs","handlingStrategy":"validation","validationCode":"// Before calling resolveAsync, confirm the Resolver was built without custom fs / module_dir_resolver\nfunction canResolveAsync(resolverOptions) {\n  return resolverOptions.fs == null && resolverOptions.moduleDirResolver == null;\n}\nif (!canResolveAsync(originalOptions)) {\n  // use sync resolve instead\n  return resolver.resolve(opts);\n}\nreturn await resolver.resolveAsync(opts);","typeGuard":"function resolverSupportsAsync(opts) {\n  return opts.fs === undefined && opts.moduleDirResolver === undefined;\n}","tryCatchPattern":"try {\n  return await resolver.resolveAsync(opts);\n} catch (e) {\n  if (e.message.includes('does not support custom fs')) {\n    // fall back to synchronous resolution\n    return resolver.resolve(opts);\n  }\n  throw e;\n}","preventionTips":["Remember the rule: custom fs OR moduleDirResolver disables async — no workaround inside the binding.","If you need non-blocking resolution with a custom fs, run sync resolve() in a Node worker_thread.","Document on your Resolver factory which mode (sync/async) each configuration supports.","Add a unit test that asserts resolveAsync throws immediately (not in the promise) when fs is set."],"tags":["resolver","async","virtual-filesystem","configuration","unsupported"],"backgroundTag":null,"analyzedSha":"59484858a1a0bcbb71f74088956bb437a2db6505","analyzedAt":"2026-08-13T04:06:35.925Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}