bun
bun copied to clipboard
Sentry/bun will break aws textract connection
What version of Bun is running?
1.0.20
What platform is your computer?
Darwin 22.3.0 arm64 arm
What steps can reproduce the bug?
"build": "tsc",
"start": "pnpm run build && npx bun run dist/apps/event-processing/src/index.js",
running my code like this and textract code just stopped working
// can only be JPG or PNG
const genImageOcrResultSync = async (
fileBuffer: Buffer
): Promise<string | null | undefined> => {
const params = {
Document: {
Bytes: fileBuffer
}
}
try {
const command = new DetectDocumentTextCommand(params)
const result = await textractClient.send(command)
const detectedText = result.Blocks?.filter(
(block) => block.BlockType === 'LINE'
)
.map((line) => line.Text)
.join('\n')
return detectedText
} catch (error) {
console.error('Error processing the document with Textract', error)
return null
}
}
What is the expected behavior?
the function should return ocr text from the image
What do you see instead?
Error processing the document with Textract ConnectionRefused: Unable to connect. Is the computer able to access the url?
path: "http://textract.eu-west-1.amazonaws.com/"
null
Additional information
No response
Encountered the same issue when using @aws-sdk/client-cognito-identity
in combination with bun
and Sentry
.
This setup fails with ConnectionRefused: Unable to connect. Is the computer able to access the url?
import {
CognitoIdentityClient,
GetIdCommand,
} from "@aws-sdk/client-cognito-identity";
import * as Sentry from "@sentry/node";
Sentry.init({
dsn: "<dsn>",
debug: true,
});
const client = new CognitoIdentityClient({
region: "<region>",
});
const { IdentityId } = await client.send(
new GetIdCommand({
IdentityPoolId: "pool",
Logins: {
[`idp-id/user-pool-id`]: "<token>"
},
})
);
console.log(IdentityId);
Filtering out the Http
integration in sentry fixes the issue, as described here: https://github.com/getsentry/sentry-javascript/issues/9564#issuecomment-1820066885
Sentry.init({
dsn: "<dsn>",
debug: true,
integrations: (int) =>
int.filter((i) => !["Http"].includes(i.name)),
});
Seems to be related to this monkeypatch of http: https://github.com/getsentry/sentry-javascript/blob/b46a1bb6eaf9fd22362a9fdf46cb8bab6cc5ec3b/packages/node/src/integrations/http.ts#L120-L128
This has been fixed with Sentry Bun SDK 8.0.0
beta, released with https://github.com/getsentry/sentry-javascript/releases/tag/8.0.0-beta.1. Will close this issue when v8 fully releases.
Fixed with 8.0.0 of @sentry/bun
- please give it a try. Thanks!
https://docs.sentry.io/platforms/javascript/guides/bun
https://docs.sentry.io/platforms/javascript/guides/bun/migration/v7-to-v8