Commit 29caf58a by Octopus Committed by GitHub

fix(oss): use list() instead of getBucketInfo() in ensureBucket to avoid bundling issue (#6833)

When using OSS storage with Next.js, getBucketInfo() triggers
"ReferenceError: name is not defined" at startup. This happens because
the ali-oss SDK references a variable named `name` internally in its
createRequest function, which conflicts with the global `name` property
in bundled JavaScript environments.

Replacing getBucketInfo() with list({ 'max-keys': 1 }) achieves the same
goal (verifying the bucket is accessible) while avoiding the problematic
code path. The list() method is already used successfully elsewhere in
the OSS adapter.

Fixes #6552

Co-authored-by: octo-patch <octo-patch@github.com>
parent 523a9374
......@@ -107,7 +107,11 @@ export class OssStorageAdapter implements IStorage {
}
async ensureBucket(): Promise<EnsureBucketResult> {
await this.client.getBucketInfo(this.options.bucket);
// Use list() instead of getBucketInfo() to verify bucket access.
// getBucketInfo() references a variable named `name` internally which conflicts
// with JavaScript's global `name` property in bundled environments (e.g. Next.js),
// causing "ReferenceError: name is not defined".
await this.client.list({ 'max-keys': 1 }, {});
return {
exists: true,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment