Skip to content

Sentry not working with bun when compile to binary #16113

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
3 tasks done
Albertbol opened this issue Apr 23, 2025 · 3 comments
Open
3 tasks done

Sentry not working with bun when compile to binary #16113

Albertbol opened this issue Apr 23, 2025 · 3 comments

Comments

@Albertbol
Copy link

Albertbol commented Apr 23, 2025

Is there an existing issue for this?

How do you use Sentry?

Sentry Saas (sentry.io)

Which SDK are you using?

@sentry/bun

SDK Version

9.13.0

Framework Version

bun --revision 1.2.10+db2e7d7f7

Link to Sentry event

No response

Reproduction Example/SDK Setup

Do bun init blank.
index.ts

import * as Sentry from "@sentry/bun";

Sentry.init({
    dsn: SENTRY_DSN_HERE,
})

console.log("Hello via Bun!");

Dockerfile

FROM oven/bun:1.2.10-debian AS base
WORKDIR /app

FROM base AS deps
COPY package.json bun.lock ./
RUN bun install --frozen-lockfile --production

FROM base AS builder
COPY --from=deps /app/node_modules ./node_modules
COPY package.json bun.lock ./
COPY . .
RUN bun build --compile --minify --sourcemap --bytecode ./index.ts --outfile server

FROM oven/bun:1.2.10-debian AS runner
WORKDIR /app

ENV NODE_ENV=production
ENV PORT=3000

COPY --from=builder /app/server /app/server
COPY --from=deps /app/node_modules ./node_modules

EXPOSE 3000
USER bun
ENTRYPOINT ["/app/server"]

run docker build and docker run you get:

126 | `,t:"\t"};function sI8(f){return f.replace(tV7,function(O,Y){switch(Y){case"\\":case"":return Y;default:return sV7[Y]||""}})}eI8.unescape=sI8;function eI8(f,O){f=f.toString();var Y=0,J=f.length,$=1,q=0,H={},Z=[],G=null;function w(_){return Error("illegal "+_+" (line "+$+")")}function X(){var _=G==="'"?gV7:pV7;_.lastIndex=Y-1;var B=_.exec(f);if(!B)throw w("string");return Y=_.lastIndex,C(G),G=null,sI8(B[1])}function K(_){return f.charAt(_)}function W(_,B,d){var Q={type:f.charAt(_++),lineEmpty:!1,leading:d},c;if(O)c=2;else c=3;var k=_-c,Z1;do if(--k<0||(Z1=f.charAt(k))===`


127 | `){Q.lineEmpty=!0;break}while(Z1===" "||Z1==="\t");var w1=f.substring(_,B).split(oV7);for(var P1=0;P1<w1.length;++P1)w1[P1]=w1[P1].replace(O?aV7:mV7,"").trim();Q.text=w1.join(`


128 | `).trim(),H[$]=Q,q=$}function P(_){var B=T(_),d=f.substring(_,B),Q=/^\s*\/\//.test(d);return Q}function T(_){var B=_;while(B<J&&K(B)!==`


129 | `)B++;return B}function A(){if(Z.length>0)return Z.shift();if(G)return X();var _,B,d,Q,c,k=Y===0;do{if(Y===J)return null;_=!1;while(rV7.test(d=K(Y))){if(d===`


130 | `)k=!0,++$;if(++Y===J)return null}if(K(Y)==="/"){if(++Y===J)throw w("comment");if(K(Y)==="/")if(!O){c=K(Q=Y+1)==="/";while(K(++Y)!==`


131 | `)if(Y===J)return null;if(++Y,c)W(Q,Y-1,k),k=!0;++$,_=!0}else{if(Q=Y,c=!1,P(Y-1)){c=!0;do{if(Y=T(Y),Y===J)break;if(Y++,!k)break}while(P(Y))}else Y=Math.min(J,T(Y)+1);if(c)W(Q,Y,k),k=!0;$++,_=!0}else if((d=K(Y))==="*"){Q=Y+1,c=O||K(Q)==="*";do{if(d===`


^


SyntaxError: import.meta is only valid inside modules.


at <parse> (/$bunfs/root/server:131:1)




Bun v1.2.10 (Linux arm64)


Steps to Reproduce

Described above

Expected Result

Should not crash

Actual Result

Crashing

@lforst
Copy link
Member

lforst commented Apr 23, 2025

Hi, would you mind also raising this issue upstream to bun? I don't think we're doing anything unorthodox in the SDK to trigger this.

@Albertbol
Copy link
Author

Hey, yes i did oven-sh/bun#19204

currently states:

Experimental: Bytecode compilation is an experimental feature introduced in Bun v1.1.30. Only cjs format is supported (which means no top-level-await). Let us know if you run into any issues!

at https://bun.sh/docs/bundler/executables#bytecode-compilation

@lforst
Copy link
Member

lforst commented Apr 23, 2025

Great! Thank you. Let's wait for their answer.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: No status
Development

No branches or pull requests

2 participants