{"action":"created","issue":{"url":"https://api.github.com/repos/gopherjs/gopherjs/issues/178","labels_url":"https://api.github.com/repos/gopherjs/gopherjs/issues/178/labels{/name}","comments_url":"https://api.github.com/repos/gopherjs/gopherjs/issues/178/comments","events_url":"https://api.github.com/repos/gopherjs/gopherjs/issues/178/events","html_url":"https://github.com/gopherjs/gopherjs/issues/178","id":58171214,"number":178,"title":"\"Error: cannot internalize\" into custom wrapper of js.Object when it returns null","user":{"login":"fabioberger","id":2151492,"avatar_url":"https://avatars.githubusercontent.com/u/2151492?v=3","gravatar_id":"","url":"https://api.github.com/users/fabioberger","html_url":"https://github.com/fabioberger","followers_url":"https://api.github.com/users/fabioberger/followers","following_url":"https://api.github.com/users/fabioberger/following{/other_user}","gists_url":"https://api.github.com/users/fabioberger/gists{/gist_id}","starred_url":"https://api.github.com/users/fabioberger/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fabioberger/subscriptions","organizations_url":"https://api.github.com/users/fabioberger/orgs","repos_url":"https://api.github.com/users/fabioberger/repos","events_url":"https://api.github.com/users/fabioberger/events{/privacy}","received_events_url":"https://api.github.com/users/fabioberger/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-02-19T06:00:37Z","updated_at":"2015-02-19T18:06:26Z","closed_at":null,"body":"When tab is null, if the return type in the callback is simply js.Object, it will return \"null\": \r\n\r\n```go\r\nfunc (t *Tabs) GetCurrent(callback func(tab js.Object))\r\n```\r\n\r\nwhereas if the return type is a custom struct with js.Object embedded within it, a javascript error occurs:\r\n\r\n```go\r\nfunc (t *Tabs) GetCurrent(callback func(tab Tab))\r\n```\r\n\r\nThe error is: \r\n\r\n```js\r\nError in response to tabs.getCurrent: \r\n     Error: cannot internalize chrome.Tab\r\n```\r\n\r\nWhere chrome.Tab is:\r\n\r\n```go\r\ntype Tab js.Object\r\n```\r\n\r\nThis ends up creating runtime javascript errors for any custom struct with js.Object embedded within it whenever it returns null instead of the actual object expected. Is this avoidable? It makes for very poor error handling.\r\n"},"comment":{"url":"https://api.github.com/repos/gopherjs/gopherjs/issues/comments/75103736","html_url":"https://github.com/gopherjs/gopherjs/issues/178#issuecomment-75103736","issue_url":"https://api.github.com/repos/gopherjs/gopherjs/issues/178","id":75103736,"user":{"login":"fabioberger","id":2151492,"avatar_url":"https://avatars.githubusercontent.com/u/2151492?v=3","gravatar_id":"","url":"https://api.github.com/users/fabioberger","html_url":"https://github.com/fabioberger","followers_url":"https://api.github.com/users/fabioberger/followers","following_url":"https://api.github.com/users/fabioberger/following{/other_user}","gists_url":"https://api.github.com/users/fabioberger/gists{/gist_id}","starred_url":"https://api.github.com/users/fabioberger/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fabioberger/subscriptions","organizations_url":"https://api.github.com/users/fabioberger/orgs","repos_url":"https://api.github.com/users/fabioberger/repos","events_url":"https://api.github.com/users/fabioberger/events{/privacy}","received_events_url":"https://api.github.com/users/fabioberger/received_events","type":"User","site_admin":false},"created_at":"2015-02-19T18:06:26Z","updated_at":"2015-02-19T18:06:26Z","body":"Thanks for the reply Neelance, \r\n\r\nBelow is the original Tab object I was trying it with and getting the same error. I have also tried just a simple struct with only the embedded js.Object and am getting the same error. Any ideas?\r\n\r\n```go\r\ntype Tab struct {\r\n\tjs.Object\r\n\tId          int    `js:\"id\"`\r\n\tIndex       int    `js:\"index\"`\r\n\tWindowId    int    `js:\"windowId\"`\r\n\tOpenerTabId int    `js:\"openerTabId\"`\r\n\tSelected    bool   `js:\"selected\"`\r\n\tHighlighted bool   `js:\"highlighted\"`\r\n\tActive      bool   `js:\"active\"`\r\n\tPinned      bool   `js:\"pinned\"`\r\n\tUrl         string `js:\"url\"`\r\n\tTitle       string `js:\"title\"`\r\n\tFavIconUrl  string `js:\"favIconUrl\"`\r\n\tStatus      string `js:\"status\"`\r\n\tIncognito   bool   `js:\"incognito\"`\r\n\tWidth       int    `js:\"width\"`\r\n\tHeight      int    `js:\"height\"`\r\n\tSessionId   string `js:\"sessionId\"`\r\n}\r\n```"}}