{"record":{"id":"5a599716029a0707","repo":"apify/crawlee","slug":"cannot-open-storage-with-alias-alias-because","errorCode":null,"errorMessage":"Cannot open storage with alias \"${alias}\" because a named storage with the same identifier already exists.","messagePattern":"Cannot open storage with alias \"(.+?)\" because a named storage with the same identifier already exists\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/core/src/storages/storage_instance_manager.ts","lineNumber":132,"sourceCode":"                        keyMap.delete(cacheKey);\n                    }\n                }\n            }\n        }\n    }\n\n    /**\n     * Ensure that the same string is not used as both a name and an alias for the same\n     * storage class + backend combination. Mirrors crawlee-python's `_check_name_alias_conflict`.\n     */\n    checkNameAliasConflict<T extends IStorage>(\n        cls: Constructor<T>,\n        { name, alias, backendCacheKey }: { name?: string; alias?: string; backendCacheKey: Hashable },\n    ): void {\n        if (alias) {\n            const existingByName = this.byName.get(cls)?.get(alias)?.get(backendCacheKey);\n            if (existingByName) {\n                throw new Error(\n                    `Cannot open storage with alias \"${alias}\" because a named storage with the same identifier already exists.`,\n                );\n            }\n        }\n        if (name) {\n            const existingByAlias = this.byAlias.get(cls)?.get(name)?.get(backendCacheKey);\n            if (existingByAlias) {\n                throw new Error(\n                    `Cannot open storage with name \"${name}\" because an alias storage with the same identifier already exists.` +\n                        ` If you meant to open the alias storage, use { alias: \"${name}\" } instead.`,\n                );\n            }\n        }\n    }\n\n    /** Iterate all cached instances across all storage types. */\n    *allValues(): IterableIterator<IStorage> {\n        const seen = new Set<IStorage>();","sourceCodeStart":114,"sourceCodeEnd":150,"githubUrl":"https://github.com/apify/crawlee/blob/dbe57fb09ca607ad59dcf998f3925ef9ac3bb26c/packages/core/src/storages/storage_instance_manager.ts#L114-L150","documentation":"StorageInstanceManager throws this when opening a storage with an `alias` that collides with an already-open named storage of the same class and backend cache key. Names and aliases share one identifier space per storage type, so an alias cannot shadow an existing explicit name.","triggerScenarios":"Calling e.g. RequestQueue.open({ alias: 'foo' }) (or KeyValueStore/Dataset equivalents) after RequestQueue.open({ name: 'foo' }) was already opened in the same process with the same backend.","commonSituations":"Refactoring code from named to aliased storages while old named opens still run; mixing config styles across modules where one module uses name and another alias for the same logical storage.","solutions":["Rename the alias to a unique value","Use the existing named storage instead of opening an alias","Call open with { name: alias } (the name form) if you intend to reuse the named storage","Audit all open() call sites to consistently use either name or alias"],"exampleFix":"// before\nawait RequestQueue.open({ name: 'my-queue' });\nawait RequestQueue.open({ alias: 'my-queue' }); // throws\n// after\nawait RequestQueue.open({ name: 'my-queue' });\nawait RequestQueue.open({ alias: 'my-queue-alt' });","handlingStrategy":"validation","validationCode":"function assertNoNameAliasConflict(openOpts) {\n  if (openOpts.alias && openedNames.has(openOpts.alias)) {\n    throw new Error(`Alias \"${openOpts.alias}\" collides with an existing named storage`);\n  }\n}","typeGuard":"null","tryCatchPattern":"try {\n  store = await RequestQueue.open({ alias });\n} catch (err) {\n  if (/alias .* because a named storage/.test(String(err))) {\n    store = await RequestQueue.open({ name: alias });\n  } else throw err;\n}","preventionTips":["Standardize on one identifier convention (name xor alias) per project","Keep a registry of opened storage identifiers in shared code","Use unique prefixes per module for storage identifiers"],"tags":["storage","naming-conflict","configuration"],"backgroundTag":"storage-identifier-conflict","analyzedSha":"dbe57fb09ca607ad59dcf998f3925ef9ac3bb26c","analyzedAt":"2026-08-30T22:22:28.328Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}