-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Open
Labels
bugSomething isn't workingSomething isn't workingconsoleRelated to console apisRelated to console apis
Description
What version of Bun is running?
1.2.22+6bafe2602
What platform is your computer?
Darwin 24.6.0 arm64 arm
What steps can reproduce the bug?
In Node.js, if you attach custom properties to an array, console.log
will print both the array elements and the extra properties — even if the array is empty.
In Bun, the behaviour is inconsistent:
- For non-empty arrays, extra properties are printed as expected.
- For empty arrays, extra properties are not shown in the console output.
Example
// Case 1: empty array with extra property
const a = [];
a.field = 1;
console.log(a);
// Case 2: non-empty array with extra property
const b = [1, 2, 3];
b.field = 1;
console.log(b);
Node.js output
[ field: 1 ]
[ 1, 2, 3, field: 1 ]
Bun output
[]
[ 1, 2, 3, field: 1 ]
What is the expected behavior?
console.log
should consistently print custom properties on arrays, regardless of whether the array is empty or not.
This would align with Node.js behaviour:
[ field: 1 ]
[ 1, 2, 3, field: 1 ]
What do you see instead?
In Bun, console.log
omits the custom property when the array is empty:
[]
[ 1, 2, 3, field: 1 ]
Additional information
This issue impacts Bun’s SQL client (bun:sql
).
For example:
- When
sql`SELECT ...`
returns non-empty results,console.log
prints both the rows and the extra metadata fields (count
,command
,lastInsertRowid
,affectedRows
). - When the result is an empty array,
console.log
prints only[]
and does not show these metadata fields. - Similarly,
sql`UPDATE ...`
often returns an empty array, and the metadata is not visible in console output.
This discrepancy makes debugging SQL queries more difficult compared to Node.js.
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't workingconsoleRelated to console apisRelated to console apis