Failed to read the 'signal' property from 'RequestInit': Failed to convert value to 'AbortSignal'. #3854
-
I connected AbortController according to the documentation, but this exception occurs, I am not sure if it is my problem or there is a bug in the sdk https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/index.html#abortcontroller-usage my demo import { AbortController } from '@aws-sdk/abort-controller';
async putObjectSend() {
this.abortController = new AbortController();
try {
const body = this.file;
const { bucket_name, object_name } = this.uploadToken.token;
const { dataMime } = this.uploadOptions;
const command = new PutObjectCommand({
Body: body,
Bucket: bucket_name,
Key: object_name,
ContentType: dataMime || body.type,
});
const response = await this.client.send(command, {
abortSignal: this.abortController.signal,
});
return response;
} catch (error) {
console.log('==error==', error);
}
} Throw an exception
|
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
Hi @ZengTianShengZ, thanks for reaching out. Could you please provide more details for when this error occurs?, does it happen when running the example above?. In my example below I did not get any issues: import {S3Client, PutObjectCommand} from "@aws-sdk/client-s3";
import {AbortController} from "@aws-sdk/abort-controller";
import {fromIni} from "@aws-sdk/credential-providers";
const abortController = new AbortController();
const client = new S3Client({
region: 'us-east-2',
credentials: fromIni({profile: 'default'})
});
const command = new PutObjectCommand({
Bucket: 'herrergy-sample-bucket',
Key: 'herrergy-sample-new-key.txt',
Body: '#'.repeat(1024 * 1024)
});
const response = await client.send(command, {
abortSignal: abortController.signal
});
console.log(response); Output: {
'$metadata': {
httpStatusCode: 200,
requestId: undefined,
extendedRequestId: 'REQUEST-ID',
cfId: undefined,
attempts: 1,
totalRetryDelay: 0
},
ETag: '"E-TAG"'
}
Thanks! |
Beta Was this translation helpful? Give feedback.
-
Hello! Reopening this discussion to make it searchable. |
Beta Was this translation helpful? Give feedback.
Hi @ZengTianShengZ, thanks for reaching out. Could you please provide more details for when this error occurs?, does it happen when running the example above?. In my example below I did not get any issues: