-
-
Notifications
You must be signed in to change notification settings - Fork 444
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
Labels
Comments
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
3 tasks
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
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.
hono/client
instance (e.g.const client = hc<AppType>(API_URL)
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()
andclient.name.toString()
. But because the client creates proxy objects for methods, it tries to return a instance ofClientRequestImpl
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
The text was updated successfully, but these errors were encountered: