Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

bug: [Web] CapacitorSQLite.getFromHTTPRequest resolves on 200 with empty body and “hangs” on 404

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

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

Đánh giá

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

Hướng nghiên cứu

Bắt đầu từ phần triển khai Web của CapacitorSQLite.getFromHTTPRequest và tái hiện hai URL được nêu trong issue: phản hồi 200 với body rỗng và phản hồi 404. Kiểm tra hành vi Web hiện có cùng mọi bài kiểm thử hoặc entry point liên quan. Công việc được hoàn tất khi các phản hồi non-OK có thể truy cập và các body rỗng không còn được resolve thành công hoặc chờ vô thời hạn.

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

Mô tả

bug/fix needs: triage

Plugin version:

@capacitor-community/sqlite 7.0.0

Platform(s):

Web (tested on Chrome 139, Windows 10).
(App works differently on native; issue appears specific to Web.)

Current behavior:

  • When the URL returns HTTP 200 with an empty body (e.g., Content-Length: 0), CapacitorSQLite.getFromHTTPRequest(options) resolves without error even though nothing is downloaded/imported.
  • When the URL returns HTTP 404, the Promise neither resolves nor rejects (appears to hang/freezes), leaving the caller waiting indefinitely.

Expected behavior:

  • On non-OK responses (e.g., 404), the Promise should reject with a meaningful error (e.g., HTTP 404).
  • On 200 with empty body (Content-Length: 0 or blob.size === 0), the Promise should reject (e.g., Empty response body) because there is nothing to import.
  • Ideally, minimal content validation (when expecting a DB/ZIP) should prevent a false positive “success.”

Steps to reproduce:

  1. Run the app on Web (not installed PWA).
  2. Call getFromHTTPRequest with a URL that returns 200 but empty body, e.g. https://httpbin.org/bytes/0.
  3. Call it again with a URL that returns 404, e.g. https://httpbin.org/status/404.
  4. Observe that the first call resolves “success” despite no data; the second call never resolves or rejects.

Related code:

import { CapacitorSQLite, capSQLiteHTTPOptions } from '@capacitor-community/sqlite';

async function test(url: string) {
  const options: capSQLiteHTTPOptions = {
    url,
    overwrite: true,
  };
  console.time(url);
  try {
    await CapacitorSQLite.getFromHTTPRequest(options);
    console.log('RESOLVED (unexpected if empty body or 404):', url);
  } catch (err) {
    console.error('REJECTED (expected on HTTP errors or empty body):', url, err);
  } finally {
    console.timeEnd(url);
  }
}

// A) 200 with empty body
test('https://httpbin.org/bytes/0');    // 200 OK, Content-Length: 0

// B) 404
test('https://httpbin.org/status/404'); // 404 Not Found

Other information:

  • Browser: Chrome 139 on Windows 10.
  • Framework: Ionic/Angular [please fill].
  • Repro was done “from web”; not an installed PWA.
  • With generic pages that return 200 but not a valid DB/ZIP (e.g., https://www.google.com), the call can also resolve, suggesting missing content validation on Web.
  • CORS: endpoints with CORS disabled correctly throw CORS errors (unrelated); the bug here is about reachable URLs returning 200/404.
  • Likely Web-only: fetch doesn’t throw on 404 (ok === false), so explicit handling and/or a timeout/AbortController might be missing in the Web implementation.
Ngôn ngữ chính
Swift
Star
663
Fork
159
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Chuẩn bị môi trường

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.

Issue khác của capacitor-community/sqlite

Tất cả issue của capacitor-community/sqlite

Issue tương tự

Thêm issue về Swift

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.