Skip to content

Top level date parsing fails on client #1812

@SebbeBroman

Description

@SebbeBroman

What version of Elysia is running?

1.4.28

What platform is your computer?

Darwin 25.3.0 arm64 arm

What environment are you using

Bun 1.3.11

Are you using dynamic mode?

Same behavior in both

What steps can reproduce the bug?

import { Elysia } from 'elysia'
import { treaty } from '@elysiajs/eden'

export const app = new Elysia()
	.get('myroute', () => new Date(), {})
	.listen(3000)

const apiRPC = treaty(app)
const api = treaty<typeof app>('localhost:3000')

const { data: rpcData } = await apiRPC.myroute.get()
console.log(rpcData)
console.log(rpcData?.getFullYear())

const { data: apiData } = await api.myroute.get()
console.log(apiData)
console.log(apiData?.getFullYear())

2026-03-20T07:56:11.000Z
2026
ArrayBuffer(66) [ 70, 114, 105, 32, 77, 97, 114, 32, 50, 48, 32, 50, 48, 50, 54, 32, 48, 56, 58, 53, 54, 58, 49, 49, 32, 71, 77, 84, 43, 48, 49, 48, 48, 32, 40, 67, 101, 110, 116, 114, 97, 108, 32, 69, 117, 114, 111, 112, 101, 97, 110, 32, 83, 116, 97, 110, 100, 97, 114, 100, 32, 84, 105, 109, 101, 41 ]
12 | console.log(rpcData)
13 | console.log(rpcData?.getFullYear())
14 |
15 | const { data: apiData } = await api.myroute.get()
16 | console.log(apiData)
17 | console.log(apiData?.getFullYear())
                          ^
TypeError: apiData?.getFullYear is not a function. (In 'apiData?.getFullYear()', 'apiData?.getFullYear' is undefined)

What is the expected behavior?

That the results are the same if you pass the app or the connection url.

What do you see instead?

No response

Additional information

When passing the app instance to treaty it parses the date correctly, however, passing the url the date is parsed correctly resulting in an arraybuffer.
It seems like when its a bare date elysia/bun returns it as a application/octet-stream with the date string as bytes.

Have you try removing the node_modules and bun.lockb and try again yet?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions