Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

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

未关闭
#656 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
3/5
预计耗时
1-2 天
新手友好度
45/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
停滞
技术栈
sqlite, typescript
领域
databases, web-dev

调研方向

从 CapacitorSQLite.getFromHTTPRequest 的 Web 实现入手,复现 issue 中的两个 URL:带有空 body 的 200 响应,以及 404 响应。检查现有的 Web 行为以及任何相关的测试或入口点。当可访问的非 OK 响应和空 body 不再成功 resolve 或无限期等待时,即表示完成。

由索引模型根据 Issue 内容生成。

描述

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.
主要语言
Swift
星标
664
派生
159
PR 合并指标
30 天内没有已合并 PR

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

capacitor-community/sqlite 的其他 Issue

查看 capacitor-community/sqlite 的全部 Issue

相似的 Issue

更多 Swift Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。