oven-sh / oven-sh/bun

Error message pointing to wrong line

Open
#17,153 5 comments 0 reactions 0 assignees View on GitHub
bug sourcemaps transpiler
Dominant language
Rust
Stars
96k
Forks
5k
Avg merge
19h 29m
Merged PRs (30d)
190

Description

### What version of Bun is running?

1.2.2+c1708ea6a

### What platform is your computer?

Darwin 24.3.0 arm64 arm

### Similar issues

- #9994
- #10228
- #14700

### What steps can reproduce the bug?

Image

Example file:

```ts
import { zodResponseFormat } from "openai/helpers/zod";
import { TGChannel } from "./oop/channel";
import { JOB_REGEXP, RESUME_REGEXP } from "./regex";
import { postGptResponse } from "./schema";
import type { IPost, IScrape } from "./types";
import { client } from "../api";

export class ResumeAndJob extends TGChannel {
private page = 1;
private cursor!: number;
private limit: number = 20;
async scrape(): Promise {
const response = await this.parse(this.cursor);

const data = (
await Promise.all(
response.map(async ({ content, ...post }): Promise => {
if (!content) {
return null;
}

const kind: "resume" | "job" | null = RESUME_REGEXP.test(content)
? "resume"
: JOB_REGEXP.test(content)
? "job"
: null;

const chatCompletion = await client.chat.completions.create({
messages: [
{
role: "user",
content:
"Response the mail address (which should both `@` and `.` text, if exists or return empty string) and salary or expected salary. Default currency is RUB",
},
{ role: "user", content },
],
model: "gpt-4o-2024-11-20",
stream: false,
response_format: zodResponseFormat(postGptResponse, "postResponse"),
max_completion_tokens: 128,
});
const [{ message }] = chatCompletion.choices;

if (!message.content) {
return null;
}

return {
...post,
kind,
...(JSON.parse(message.content) as Pick),
};
})
)
).filter((post) => post) as IPost[]; // <-- This is where bug?
const [{ id }] = data;

// Set limit
if (!this.limit) {
this.limit = data.length;
}
this.cursor = id - (this.page - 1) * this.limit;

return { data, count: data.length, cursor: this.cursor, page: this.page };
}
next() {
this.page++;

return this.scrape();
}
prev() {
if (this.page > 1) {
this.page--;
} else {
throw new Error("No next elements");
}

return this.scrape();
}
}

```

### What is the expected behavior?

Running fine as a some older version of `bun`

### What do you see instead?

Image

### Additional information

_No response_

Contributor guide

Open the contributing guide

Research direction

Reproduce the reported error with Bun 1.2.2+c1708ea6a using the TypeScript example in the issue, then compare the reported location with the actual failing expression. Trace Bun's error-reporting path to identify why the message points to the wrong line; done means the same reproduction identifies the correct source line and relevant regression coverage exists.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, rust, typescript
Domain
devtools
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.