question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Repeated 'Error: "toString()" failed' on launch.

See original GitHub issue

Description

As of yesterday, whenever I try to open Desktop, it tries to sync and then crashes.

Version

GitHub Desktop version: Unknown - (Latest I think?)

OS version: Windows 10 (Home), Version 1703, Build 15063.296

Steps to Reproduce

  1. Open GitHub Desktop…
  2. Wait for it to try and sync…
  3. Watch your hopes and dreams crumble.

I have two repos cloned in Desktop; https://github.com/rivermont/spidy and https://github.com/rivermont/instagram-graph.

It opens to spidy, and it appears that there is a push that it never manages to send before crashing.

Expected behaviour: Open GitHub Desktop without problems.

Actual behaviour: After opening, Desktop tries to sync and then crashes.

Reproduces how often: 100% of the time.

Attempted Debugging

  • Force quit Desktop from Task Manager
  • Restart computer.
  • Push the commit really fast before it crashes.
  • Run Update.exe from \AppData\Local\GitHubDesktop\

###Logs

Crash Report Displayed in a nice red box with a single Quit button:

GitHub Desktop encountered an uncaught exception, leaving it in an invalid state.

Error: “toString()” failed at Uint8Array.Buffer.toString (buffer.js:503:11) at StringDecoder.utf8Text [as text] (string_decoder.js:180:16) at StringDecoder.write (string_decoder.js:64:46) at readableAddChunk (_stream_readable.js:164:31) at Socket.Readable.push (_stream_readable.js:134:10) at Pipe.onread (net.js:551:20)

Crash Logs Stolen from \AppData\Roaming\GitHub Desktop\logs\:

2017-05-29T02:21:13.993Z - error: Uncaught exception on renderer process Error: “toString()” failed at Uint8Array.Buffer.toString (buffer.js:503:11) at StringDecoder.utf8Text [as text] (string_decoder.js:180:16) at StringDecoder.write (string_decoder.js:64:46) at readableAddChunk (_stream_readable.js:164:31) at Socket.Readable.push (_stream_readable.js:134:10) at Pipe.onread (net.js:551:20)

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:20 (14 by maintainers)

github_iconTop GitHub Comments

1reaction
shiftkeycommented, Jun 2, 2017

So I’ve nailed this down to the file contents and how we handle this in the app.

To begin with, let’s just read the file in using less on Windows. We get to line 282 and it then starts spitting out garbage characters:

    275 https://twitter.com/search?q=%23ycc2015%20AND%20%23U16B&f=tweets&lang=ca
    276 https://twitter.com/search?q=%23ycc2015%20AND%20%23U16B&lang=zh-tw&f=tweets
    277 https://abs.twimg.com/a/1495774371/css/t1/twitter_core.bundle.css
    278 https://abs.twimg.com/a/1495774371/img/search/ic_places_yelp_logo.png
    279 http://play.usaultimate.org/events/2016-Northeastern-High-School-Regional-Championships/schedule/Girls/High-S    279 chool-Girls/
    280 http://www.usaultimate.org/news/2012-hs-states-nominations-coty-mixed/
    281 http://usaultimate.org/archives/2016_youth.aspx#about
    282 http://play.usaultimate.org/events/2016-Georgia-High-School-Girls-State-Championship\\\\\\\\\\\\\\\\\\\\\\\\\   
282 \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
282 \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
282 \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
282 \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
282 \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\

Changing this up to use git diff you’ll see the same thing:

$ git diff HEAD --no-ext-diff --patch-with-raw -z --no-color -- crawler_done.txt
...
+https://twitter.com/search?q=%23ycc2015%20AND%20%23U16B&f=tweets&lang=ca
+https://twitter.com/search?q=%23ycc2015%20AND%20%23U16B&lang=zh-tw&f=tweets
+https://abs.twimg.com/a/1495774371/css/t1/twitter_core.bundle.css
+https://abs.twimg.com/a/1495774371/img/search/ic_places_yelp_logo.png
+http://play.usaultimate.org/events/2016-Northeastern-High-School-Regional-Championships/schedule/Girls/High-School-Girls/
+http://www.usaultimate.org/news/2012-hs-states-nominations-coty-mixed/
+http://usaultimate.org/archives/2016_youth.aspx#about
+http://play.usaultimate.org/events/2016-Georgia-High-School-Girls-State-Championship\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\

For reference, on MacOS this problem file is detected as binary:

$ git diff HEAD --no-ext-diff --patch-with-raw -z --no-color -- crawler_done.txt
:100644 100644 e69de29... 0000000... M^@crawler_done.txt^@^@diff --git a/crawler_done.txt b/crawler_done.txt
index e69de29..f394c0a 100644
Binary files a/crawler_done.txt and b/crawler_done.txt differ

I’ve traced this behaviour through to string_bytes.cc.

      val = String::NewFromUtf8(isolate,
                                buf,
                                String::kNormalString,
                                buflen);

As this isn’t doing any encoding detection, and just failing quietly when it encounters the corrupted bytes, we have a couple of options:

  • propose a patch to https://github.com/electron/node to handle this better and update Electron in the future. I’m not sure what the right behaviour should be here, but maybe some inspiration will strike. We’re also currently blocked on https://github.com/electron/electron/issues/9583 which is also Windows-specific, so I’m hesitant to go too further with this.
  • switch the diff output over to binary output and attempt the encoding in the app, so we can handle this failure gracefully. I spiked this out in #634 but the diff parsing code has changed since then, so it’s not as simple as cherry-picking some commits over.
0reactions
shiftkeycommented, Jun 2, 2017

@joshaber yeah, that’s the way I’m heading right now to make the crashes go away sooner 😛

Read more comments on GitHub >

github_iconTop Results From Across the Web

Error: toString failed · Issue #7388 · nodejs/node - GitHub
Node server using socket.io is getting hit by some kind of attack that makes it crash, with the error "toString failed".
Read more >
Errors testing toString Java code [duplicate] - Stack Overflow
Currently it is using the default toString() functionality, which returns the object type and hash code. Here is what your method could look ......
Read more >
Error - JavaScript - MDN Web Docs - Mozilla
Creates an instance representing several errors wrapped in a single error when multiple errors need to be reported by an operation, for example ......
Read more >
Process | Node.js v19.3.0 Documentation
The 'rejectionHandled' event is emitted whenever a Promise has been rejected and an error handler was attached to it (using promise.catch() , for...
Read more >
Partial Failure - Ads API - Google Developers
In the Google Ads API, you can request that valid operations be committed and failed ones return errors. This feature—called partial failure—lets you...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found