evanw / evanw/node-source-map-support
Browser hangs on new Buffer(...).toString() for large source maps
- 主要言語
- JavaScript
- スター
- 2.2k
- フォーク
- 223
- PR マージ指標
- 30日以内にマージされた PR はありません
説明
Hello. Found this issue during investigation of #93. We're using webpack, so I'm guessing it might be related to webpack's `Buffer` browser polyfill? (I think it uses [feross/buffer](https://github.com/feross/buffer), which is what Browserify uses?)
For large source maps, the following [line](https://github.com/evanw/node-source-map-support/blob/master/source-map-support.js#L111) caused the browser (Chrome 44.0.2403.155 (64-bit)) to choke:
``` js
sourceMapData = new Buffer(rawData, "base64").toString();
```
I tweaked this to use [`window.atob`](https://developer.mozilla.org/en-US/docs/Web/API/WindowBase64/atob) when in the browser:
``` js
if (isInBrowser()) {
sourceMapData = window.atob(rawData);
} else {
sourceMapData = new Buffer(rawData, "base64").toString();
}
```
If you think that's a reasonable solution, I'm happy to set up a PR? (Haven't actually checked this change against the test suite yet though :sweat_smile:)
コントリビューションガイド
このリポジトリのコントリビューションガイドは索引されていません
調査の方向性
source-map-support.js の 111 行目から始めて、大きな source maps をデコードするブラウザパスと Node パスを調査します。テストスイートを実行し、その後、ブラウザパスでハングを回避できる一方、Node パスは変更されず、大きな source maps が正常に処理されることを確認します。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- javascript, webpack
- 領域
- devtools, web-dev
- issue の種類
- バグ
- 難易度
- 2/5
- 見積もり時間
- 1〜3時間
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 52/100