sql-js / sql-js/sql.js

When calling functions on a closed database, confusing "out of memory" error is reported

Đang mở
#201 8 bình luận 1 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

bug
Ngôn ngữ chính
JavaScript
Star
13.7k
Fork
1.1k
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Mô tả

I realize that calling methods on a database that's been closed is not a good idea. However, when calling a method like each on the closed database, the error reported is out of memory. The underlying db is nulled out on close (which makes sense). But then, in the handleError method:

Database.prototype.handleError = function(returnCode) {
    var errmsg;
    if (returnCode === SQLite.OK) {
      return null;
    } else {
      errmsg = sqlite3_errmsg(this.db);
      throw new Error(errmsg);
    }
  };

We're passing null into the sqlite3_errmsg. That in turn causes it to report it as a memory allocation error.

Ideally, the error reported would be something more intuitive. I bring this up because I am now closing databases that we are no longer using in an effort to fix a real memory allocation error. However, in the process of doing so, I accidentally closed a database I shouldn't have and continued to get what looked like memory errors. It wasn't until later that I realized this message was inaccurate.

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Hướng nghiên cứu

Start at Database.prototype.handleError in the issue's JavaScript snippet and reproduce calling each on a closed database. Check how the null database reaches sqlite3_errmsg; done means the closed-database case reports an intuitive error instead of "out of memory."

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
javascript, sqlite
Lĩnh vực
database
Loại issue
Lỗi
Độ khó
2/5
Thời gian dự kiến
1-3 giờ
Mức độ hoạt động
Đình trệ
Độ rõ ràng
Khá rõ ràng
Mức phù hợp với người mới
35/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.