Repository navigation
Closed
Description
Is there an existing issue for this?
- I have checked for existing issues https://github.com/getsentry/sentry-javascript/issues
- I have reviewed the documentation https://docs.sentry.io/
- I am using the latest SDK release https://github.com/getsentry/sentry-javascript/releases
How do you use Sentry?
Sentry Saas (sentry.io)
Which SDK are you using?
@sentry/node
SDK Version
^9.25.1
Framework Version
No response
Link to Sentry event
No response
Reproduction Example/SDK Setup
No response
Steps to Reproduce
I am using this function to put onto s3:
export const s3put = async (key, val, options) => {
const { acl, contentType } = options || {};
const params = {
Bucket: bucket,
Key: key,
Body: val,
ContentType: contentType,
ACL: acl,
};
try {
await s3.send(new PutObjectCommand(params));
} catch (e) {
console.error('s3put got error:', e, params);
throw e;
}
const url = s3url(key);
return url;
};
Without Sentry, it works fine.
My Sentry instrument.js file is:
import * as Sentry_ from '@sentry/node';
export const Sentry = Sentry_;
if (process.env.ENV == 'prod') {
Sentry.init({
dsn: '...',
sendDefaultPii: true,
});
}
Expected Result
It should upload to s3
Actual Result
When I add Sentry instrumentation, I get this error:
Error [ERR_HTTP_HEADERS_SENT]: Cannot set headers after they are sent to the client
at ClientRequest.setHeader (node:_http_outgoing:699:11)
at SentryHttpInstrumentation._onOutgoingRequestCreated (/app/node_modules/@sentry/node/src/integrations/http/SentryHttpInstrumentation.ts:265:15)
at onHttpClientRequestCreated (/app/node_modules/@sentry/node/src/integrations/http/SentryHttpInstrumentation.ts:167:12)
at Channel.publish (node:diagnostics_channel:150:9)
at new ClientRequest (node:_http_client:384:35)
at request (node:https:381:10)
at /app/node_modules/@smithy/node-http-handler/dist-cjs/index.js:366:19
at new Promise (<anonymous>)
at _NodeHttpHandler.handle (/app/node_modules/@smithy/node-http-handler/dist-cjs/index.js:300:12)
at async /app/node_modules/@aws-sdk/middleware-flexible-checksums/dist-cjs/index.js:456:18 {
code: 'ERR_HTTP_HEADERS_SENT'
}
Reacted by Nathan Sarang-Walters
Metadata
Metadata
Assignees
Projects
- StatusShow more project fieldsWaiting for: Product Owner
Activity
nwalters512 commentedon Jun 3, 2025
I'm seeing exactly the same error, though with a slightly different stack trace:
I also believe this is related to S3, and the error definitely comes from Sentry internals.
nwalters512 commentedon Jun 3, 2025
This is probably a duplicate of #16438.
RulaKhaled commentedon Jun 4, 2025
This should be fixed with fix(node): Ensure adding sentry-trace and baggage headers via SentryHttpInstrumentation doesn't crash #16473
strongpauly commentedon Jun 4, 2025
Downgrading to
9.15.0fixes this.federico-conte-79 commentedon Jun 4, 2025
Same problem also for us; we downgraded successfully to
9.22.0(any version greater than this doesn't work).andreiborza commentedon Jun 4, 2025
We just released
9.26.0which should fix this, please upgrade.nwalters512 commentedon Jun 4, 2025
I can confirm that this fixed the issue for my applications. Thanks for the quick turnaround!