Skip to content

Commit

Permalink
Merge branch 'main' into jarred/fixes-14716
Browse files Browse the repository at this point in the history
  • Loading branch information
Jarred-Sumner authored Oct 26, 2024
2 parents c7677dc + 2d9a73f commit 18b83ef
Show file tree
Hide file tree
Showing 5 changed files with 118 additions and 5 deletions.
56 changes: 55 additions & 1 deletion .github/workflows/labeled.yml
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,26 @@ jobs:
echo "latest=$(cat LATEST)" >> $GITHUB_OUTPUT
rm -rf is-outdated.txt outdated.txt latest.txt
- name: Generate comment text with Sentry Link
if: github.event.label.name == 'crash'
# ignore if fail
continue-on-error: true
id: generate-comment-text
env:
GITHUB_ISSUE_BODY: ${{ github.event.issue.body }}
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_EVENTS_SECRET }}
shell: bash
run: |
bun scripts/associate-issue-with-sentry.ts
if [[ -f "sentry-link.txt" ]]; then
echo "sentry-link=$(cat sentry-link.txt)" >> $GITHUB_OUTPUT
fi
if [[ -f "sentry-id.txt" ]]; then
echo "sentry-id=$(cat sentry-id.txt)" >> $GITHUB_OUTPUT
fi
- name: Add labels
uses: actions-cool/issues-helper@v3
if: github.event.label.name == 'crash'
Expand All @@ -92,7 +112,7 @@ jobs:
issue-number: ${{ github.event.issue.number }}
labels: ${{ steps.add-labels.outputs.labels }}
- name: Comment outdated
if: steps.add-labels.outputs.is-outdated == 'true' && github.event.label.name == 'crash'
if: steps.add-labels.outputs.is-outdated == 'true' && github.event.label.name == 'crash' && steps.generate-comment-text.outputs.sentry-link == ''
uses: actions-cool/issues-helper@v3
with:
actions: "create-comment"
Expand All @@ -106,6 +126,40 @@ jobs:
```sh
bun upgrade
```
- name: Comment with Sentry Link and outdated version
if: steps.generate-comment-text.outputs.sentry-link != '' && github.event.label.name == 'crash' && steps.add-labels.outputs.is-outdated == 'true'
uses: actions-cool/issues-helper@v3
with:
actions: "create-comment"
token: ${{ secrets.GITHUB_TOKEN }}
issue-number: ${{ github.event.issue.number }}
body: |
@${{ github.event.issue.user.login }}, thank you for reporting this crash. The latest version of Bun is v${{ steps.add-labels.outputs.latest }}, but this crash was reported on Bun v${{ steps.add-labels.outputs.oudated }}.
Are you able to reproduce this crash on the latest version of Bun?
```sh
bun upgrade
```
For Bun's internal tracking, this issue is [${{ steps.generate-comment-text.outputs.sentry-id }}](${{ steps.generate-comment-text.outputs.sentry-link }}).
<!-- sentry-id: ${{ steps.generate-comment-text.outputs.sentry-id }} -->
<!-- sentry-link: ${{ steps.generate-comment-text.outputs.sentry-link }} -->
- name: Comment with Sentry Link
if: steps.generate-comment-text.outputs.sentry-link != '' && github.event.label.name == 'crash' && steps.add-labels.outputs.is-outdated != 'true'
uses: actions-cool/issues-helper@v3
with:
actions: "create-comment"
token: ${{ secrets.GITHUB_TOKEN }}
issue-number: ${{ github.event.issue.number }}
body: |
Thank you for reporting this crash.
For Bun's internal tracking, this issue is [${{ steps.generate-comment-text.outputs.sentry-id }}](${{ steps.generate-comment-text.outputs.sentry-link }}).
<!-- sentry-id: ${{ steps.generate-comment-text.outputs.sentry-id }} -->
<!-- sentry-link: ${{ steps.generate-comment-text.outputs.sentry-link }} -->
- name: Comment needs repro
if: github.event.label.name == 'needs repro'
uses: actions-cool/issues-helper@v3
Expand Down
51 changes: 51 additions & 0 deletions scripts/associate-issue-with-sentry.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
const body = process.env.GITHUB_ISSUE_BODY;
const SENTRY_AUTH_TOKEN = process.env.SENTRY_AUTH_TOKEN;

if (!body || !SENTRY_AUTH_TOKEN) {
throw new Error("Missing environment variables");
}

const id = body.indexOf("<!-- sentry_id: ");
const endIdLine = body.indexOf(" -->", id + 1);
if (!(id > -1 && endIdLine > -1)) {
throw new Error("Missing sentry_id");
}
const sentryId = body.slice(id + "<!-- sentry_id: ".length, endIdLine).trim();
if (!sentryId) {
throw new Error("Missing sentry_id");
}

const response = await fetch(`https://sentry.io/api/0/organizations/4507155222364160/eventids/${sentryId}/`, {
headers: {
Authorization: `Bearer ${SENTRY_AUTH_TOKEN}`,
},
});
if (!response.ok) {
throw new Error(`Failed to fetch Sentry event: ${response.statusText}`);
}
const json = await response.json();
const groupId = json?.groupId;
if (!groupId) {
throw new Error("Missing groupId");
}

const issueResponse = await fetch(`https://sentry.io/api/0/issues/${groupId}/`, {
headers: {
Authorization: `Bearer ${SENTRY_AUTH_TOKEN}`,
},
});
if (!issueResponse.ok) {
throw new Error(`Failed to fetch Sentry issue: ${issueResponse.statusText}`);
}
const { shortId, permalink } = await issueResponse.json();
if (!shortId || !permalink) {
throw new Error("Missing shortId or permalink");
}

console.log(`Sentry ID: ${shortId}`);
console.log(`Sentry permalink: ${permalink}`);

await Bun.write("sentry-id.txt", shortId);
await Bun.write("sentry-link.txt", permalink);

export {};
4 changes: 4 additions & 0 deletions src/bun.js/bindings/webcore/JSTextEncoder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,10 @@ static inline JSC::EncodedJSValue jsTextEncoderPrototypeFunction_encodeBody(JSC:
UNUSED_PARAM(throwScope);
UNUSED_PARAM(callFrame);
EnsureStillAliveScope argument0 = callFrame->argument(0);
if (argument0.value().isUndefined()) {
auto res = JSC::JSUint8Array::create(lexicalGlobalObject, lexicalGlobalObject->m_typedArrayUint8.get(lexicalGlobalObject), 0);
RELEASE_AND_RETURN(throwScope, JSValue::encode(res));
}
JSC::JSString* input = argument0.value().toStringOrNull(lexicalGlobalObject);
JSC::EncodedJSValue res;
String str;
Expand Down
6 changes: 2 additions & 4 deletions test/cli/install/bun-install.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,6 @@ it("should not error when package.json has comments and trailing commas", async
"dependencies": {
"bar": "^1",
},
}
`,
);
Expand Down Expand Up @@ -6348,14 +6347,14 @@ cache = false
expect(err1).toContain("Saved lockfile");
const out1 = await new Response(stdout1).text();
expect(out1.replace(/\s*\[[0-9\.]+m?s\]\s*$/, "").split(/\r?\n/)).toEqual([
expect.stringContaining("bun install v1."),
`bun install ${Bun.version_with_sha}`,
"",
"+ [email protected]",
"+ [email protected]",
"+ [email protected]",
"+ [email protected]",
"",
"120 packages installed",
"112 packages installed",
]);
expect(await exited1).toBe(0);
expect(await readdirSorted(package_dir)).toEqual(["bun.lockb", "bunfig.toml", "node_modules", "package.json"]);
Expand Down Expand Up @@ -6384,7 +6383,6 @@ cache = false
"dir-glob",
"emoji-regex",
"error-ex",
"escape-string-regexp",
"eslint-formatter-pretty",
"eslint-rule-docs",
"fast-glob",
Expand Down
6 changes: 6 additions & 0 deletions test/js/web/encoding/text-encoder.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@ it("not enough space for replacement character", () => {
});

describe("TextEncoder", () => {
it("should handle undefined", () => {
const encoder = new TextEncoder();
expect(encoder.encode(undefined).length).toBe(0);
expect(encoder.encode(null).length).toBe(4);
expect(encoder.encode("").length).toBe(0);
});
it("should encode latin1 text with non-ascii latin1 characters", () => {
var text = "H©ell©o Wor©ld!";

Expand Down

0 comments on commit 18b83ef

Please sign in to comment.