Fix error handling in pouchdb-errors to prevent crashes when Error.stack is inaccessible

オープン
#9,067 コメント 2 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
3/5
見積もり時間
1〜2日
初心者へのやさしさ
35/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
停滞
技術スタック
javascript
領域
database

調査の方向性

node_modules/pouchdb-errors/lib/index.js から始め、提供された diff を出発点として createError を調査してください。Error.stack にアクセスできない環境で失敗を再現し、その後、エラーの作成がクラッシュしなくなったことと、結果として生じるエラーの動作がテストでカバーされていることを確認してください。

索引モデルが issue の本文から書いたものです。

説明

Fix error handling in pouchdb-errors to prevent crashes when Error.stack is inaccessible

Here is the diff that solved my problem:

diff --git a/node_modules/pouchdb-errors/lib/index.js b/node_modules/pouchdb-errors/lib/index.js
index f271755..ccc388a 100644
--- a/node_modules/pouchdb-errors/lib/index.js
+++ b/node_modules/pouchdb-errors/lib/index.js
@@ -57,15 +57,25 @@ function createError(error, reason) {
       }
     }
 
-    if (this.stack === undefined) {
-      this.stack = (new Error()).stack;
+    // Safely handle the stack property
+    try {
+      if (this.stack === undefined) {
+        this.stack = (new Error()).stack;
+      }
+    } catch (e) {
+      // Fallback for environments where stack assignment fails
+      this.stack = 'No stack trace available';
     }
 
     if (reason !== undefined) {
       this.reason = reason;
     }
   }
-  CustomPouchError.prototype = PouchError.prototype;
+
+  // Ensure proper inheritance from PouchError
+  CustomPouchError.prototype = Object.create(PouchError.prototype);
+  CustomPouchError.prototype.constructor = CustomPouchError;
+
   return new CustomPouchError(reason);
 }
 

This issue body was partially generated by patch-package.

主要言語
JavaScript
スター
17.6k
フォーク
1.5k
PR マージ指標
30日以内にマージされた PR はありません

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

apache/pouchdb のほかの issue

apache/pouchdb の issue をすべて見る

似ている issue

JavaScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。