Skip to content
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

TypeError: Cannot determine default value of object #2509

Closed
ibash opened this issue Apr 15, 2024 · 0 comments · Fixed by #2510
Closed

TypeError: Cannot determine default value of object #2509

ibash opened this issue Apr 15, 2024 · 0 comments · Fixed by #2510
Labels

Comments

@ibash
Copy link
Contributor

ibash commented Apr 15, 2024

What version of Hono are you using?

4.2.3

What runtime/platform is your app running on?

Expo

What steps can reproduce the bug?

Documenting this for posterity, but will have a PR to fix on the way.

  1. Create a new expo app
  2. Instantiate a hono/client instance (e.g.const client = hc<AppType>(API_URL)
  3. console.log the client: console.log(client)

What is the expected behavior?

Logs the client object

What do you see instead?

TypeError: Cannot determine default value of object

This comes from the hermes javascript engine: facebook/hermes#205

What's happening is that when you try to console.log the client, react-native tries to console.log a function. So it calls client.name.valueOf() and client.name.toString(). But because the client creates proxy objects for methods, it tries to return a instance of ClientRequestImpl with the url of /name/valueOf and /name/toString respectively.

Fix is to catch these cases (and maybe others?) and return a string instead.

Additional information

No response

@ibash ibash added the bug label Apr 15, 2024
ibash added a commit to ibash/hono that referenced this issue Apr 15, 2024
Fixes honojs#2509

When a hono client is instantiated in expo and then console.log(client)
is called, an error is thrown:

`TypeError: Cannot determine default value of object`

This is because the hermes javascript engine expects `new String(val)`
to always return a string. But the proxy object would return a
ClientRequestImpl object instead.

This commit makes a string / function returned in the cases where
.toString() and .valueOf() is called on the function.name or function
respectively.

Also see facebook/hermes#205
ibash added a commit to ibash/hono that referenced this issue Apr 15, 2024
Fixes honojs#2509

When a hono client is instantiated in expo and then console.log(client)
is called, an error is thrown:

`TypeError: Cannot determine default value of object`

This is because the hermes javascript engine expects `new String(val)`
to always return a string. But the proxy object would return a
ClientRequestImpl object instead.

This commit makes a string / function returned in the cases where
.toString() and .valueOf() is called on the function.name or function
respectively.

Also see facebook/hermes#205
ibash added a commit to ibash/hono that referenced this issue Apr 15, 2024
Fixes honojs#2509

When a hono client is instantiated in expo and then console.log(client)
is called, an error is thrown:

`TypeError: Cannot determine default value of object`

This is because the hermes javascript engine expects `new String(val)`
to always return a string. But the proxy object would return a
ClientRequestImpl object instead.

This commit makes a string / function returned in the cases where
.toString() and .valueOf() is called on the function.name or function
respectively.

Also see facebook/hermes#205
ibash added a commit to ibash/hono that referenced this issue Apr 17, 2024
Fixes honojs#2509

When a hono client is instantiated in expo and then console.log(client)
is called, an error is thrown:

`TypeError: Cannot determine default value of object`

This is because the hermes javascript engine expects `new String(val)`
to always return a string. But the proxy object would return a
ClientRequestImpl object instead.

This commit makes a string / function returned in the cases where
.toString() and .valueOf() is called on the function.name or function
respectively.

Also see facebook/hermes#205
yusukebe pushed a commit that referenced this issue Apr 17, 2024
…2510)

Fixes #2509

When a hono client is instantiated in expo and then console.log(client)
is called, an error is thrown:

`TypeError: Cannot determine default value of object`

This is because the hermes javascript engine expects `new String(val)`
to always return a string. But the proxy object would return a
ClientRequestImpl object instead.

This commit makes a string / function returned in the cases where
.toString() and .valueOf() is called on the function.name or function
respectively.

Also see facebook/hermes#205
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant