You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
ERR_HTTP_HEADERS_SENT","$metadata":{"attempts":1,"totalRetryDelay":0}}]message: Cannot set headers after they are sent to the client
i think the agent try to set header after http send to client
here i tried test code:
import'pinpoint-node-agent';import*asfsfrom'fs';importexpressfrom'express';import{S3Client,PutObjectCommand,CreateBucketCommand}from"@aws-sdk/client-s3";// Set the AWS Region.constREGION="ap-northeast-2";//e.g. "us-east-1"// Create an Amazon S3 service client object.consts3Client=newS3Client({region: REGION});constfile=awaitfs.readFileSync(`./test.pdf`);// Set the parametersconstparams={Bucket: "",// The name of the bucket. For example, 'sample_bucket_101'.Key: "",// The name of the object. For example, 'sample_upload.txt'.Body: Buffer.from(file),// The content of the object. For example, 'Hello world!".ContentType: 'application/pdf',ACL: 'private',};construn=async()=>{// Create an object and upload it to the Amazon S3 bucket.for(leti=0;i<10;i++){try{constresults=awaits3Client.send(newPutObjectCommand({...params,Key: `path/file-name${i}.pdf`}));console.log("Successfully created "+params.Key+" and uploaded it to "+params.Bucket+"/"+params.Key+"\nresults:"+JSON.stringify(results));}catch(err){console.log("Error"+i,err);}}};constapp=express()constport=3000app.get('/',(req,res)=>{run().then(()=>{res.send('Hello World!')}).catch(e=>{res.send(e)});})app.listen(port,()=>{console.log(`Example app listening on port ${port}`)})
PINPOINT_APPLICATION_NAME=TEST PINPOINT_AGENT_ID=TEST_AGENT node index.js
curl localhost:3000
Error9 Error [ERR_HTTP_HEADERS_SENT]: Cannot set headers after they are sent to the client
at new NodeError (node:internal/errors:371:5)
at ClientRequest.setHeader (node:_http_outgoing:576:11)
at Function.setHeader (/home/node/app/test/node_modules/pinpoint-node-agent/lib/instrumentation/request-header-utils.js:93:15)
at Function.write (/home/node/app/test/node_modules/pinpoint-node-agent/lib/instrumentation/request-header-utils.js:79:12)
at /home/node/app/test/node_modules/pinpoint-node-agent/lib/instrumentation/http-shared.js:119:26
at /home/node/app/test/node_modules/@aws-sdk/node-http-handler/dist-cjs/node-http-handler.js:70:25
at new Promise (<anonymous>)
at NodeHttpHandler.handle (/home/node/app/test/node_modules/@aws-sdk/node-http-handler/dist-cjs/node-http-handler.js:49:16)
at /home/node/app/test/node_modules/@aws-sdk/client-s3/dist-cjs/commands/PutObjectCommand.js:39:58
at /home/node/app/test/node_modules/@aws-sdk/middleware-serde/dist-cjs/deserializerMiddleware.js:5:32 {
code: 'ERR_HTTP_HEADERS_SENT',
'$metadata': { attempts: 1, totalRetryDelay: 0 }
}
The text was updated successfully, but these errors were encountered:
hi
i got this error when used with aws sdk
i think the agent try to set header after http send to client
here i tried test code:
The text was updated successfully, but these errors were encountered: