Skip to content

[Bug]: ctx_fetch_and_index crashes on pages containing an empty <table> (turndown-plugin-gfm isHeadingRow) #1136

Description

@kunanaxp

Platform

OpenCode

context-mode version

1.0.169 (npm latest)

Debug script output (REQUIRED)

{
  "version": "2.0.0",
  "generated": "2026-09-06T13:10:15Z",
  "sections": {
    "1. System Info": {
      "checks": [],
      "info": {
        "OS type": "windows",
        "uname -a": "MINGW64_NT-10.0-26200 DESKTOP-0U2BOFR 3.6.9-b4195d69.x86_64 2026-06-06 17:49 UTC x86_64 Msys",
        "Architecture": "x86_64",
        "Windows ver": "Microsoft Windows [Version 10.0.26200.9278]",
        "Shell": "/usr/bin/bash",
        "Bash version": "5.3.15(1)-release",
        "Locale": "LANG=unset, LC_ALL=unset"
      },
      "configs": [],
      "warnings": [],
      "details": []
    },
    "2. Runtime Versions": {
      "checks": [],
      "info": {
        "Node.js": "v24.18.1",
        "node path": "/c/Users/kunan/scoop/apps/nvm/current/nodejs/nodejs/node",
        "execPath": "C:\\Users\\kunan\\scoop\\apps\\nvm\\current\\nodejs\\nodejs\\node.exe",
        "Node install method": "unknown",
        "Bun": "1.4.2",
        "bun path": "/c/Users/kunan/scoop/shims/bun",
        "Python": "Python 3.14.6",
        "npm": "12.0.2",
        "npm global root": "C:\\Users\\kunan\\scoop\\apps\\nvm\\current\\nodejs\\nodejs\\node_modules"
      },
      "configs": [],
      "warnings": [],
      "details": []
    },
    "3. context-mode Installation": {
      "checks": [
        {
          "pass": true,
          "label": "build/ directory exists"
        },
        {
          "pass": true,
          "label": "hooks/pretooluse.mjs exists"
        },
        {
          "pass": true,
          "label": "hooks/sessionstart.mjs exists"
        },
        {
          "pass": true,
          "label": "server.bundle.mjs exists"
        },
        {
          "pass": true,
          "label": "cli.bundle.mjs exists"
        }
      ],
      "info": {
        "Installed version": "1.0.169",
        "Plugin root": "C:/Users/kunan/.cache/opencode/packages/context-mode/node_modules/context-mode",
        "Install method": "npm global/local",
        "npm latest": "1.0.169"
      },
      "configs": [],
      "warnings": [],
      "details": []
    },
    "4. better-sqlite3 Native Module": {
      "checks": [
        {
          "pass": false,
          "label": "better-sqlite3 .node binary exists"
        },
        {
          "pass": false,
          "label": "require('better-sqlite3') succeeds"
        },
        {
          "pass": true,
          "label": "npm ignore-scripts is false"
        }
      ],
      "info": {
        "Node ABI version": "137"
      },
      "configs": [],
      "warnings": [],
      "details": []
    },
    "5. Adapter Detection": {
      "checks": [],
      "info": {
        "Active adapter (env)": "opencode",
        "Installed adapters": "claude-code codex opencode"
      },
      "configs": [],
      "warnings": [],
      "details": []
    },
    "6. Config Files": {
      "checks": [],
      "info": {
        "Claude settings.json": "/c/Users/kunan/.claude/settings.json (not found)",
        "Claude settings.local.json": "/c/Users/kunan/.claude/settings.local.json (not found)",
        "Gemini settings.json": "/c/Users/kunan/.gemini/settings.json (not found)",
        "Codex config.toml": "/c/Users/kunan/.codex/config.toml (exists)",
        "Codex hooks.json": "/c/Users/kunan/.codex/hooks.json (not found)",
        "Cursor hooks.json (project)": "/c/Users/kunan/.cursor/hooks.json (not found)",
        "Cursor mcp.json (project)": "/c/Users/kunan/.cursor/mcp.json (not found)",
        "Cursor mcp.json (global)": "/c/Users/kunan/.cursor/mcp.json (not found)",
        "Cursor hooks.json (global)": "/c/Users/kunan/.cursor/hooks.json (not found)",
        "VS Code mcp.json (project)": "/c/Users/kunan/.vscode/mcp.json (not found)",
        "opencode.json (project)": "/c/Users/kunan/opencode.json (not found)",
        "opencode.json (dotdir)": "/c/Users/kunan/.opencode/opencode.json (not found)",
        "opencode.json (global)": "/c/Users/kunan/.config/opencode/opencode.json (exists)",
        "KiloCode settings.json": "/c/Users/kunan/.config/kilo/settings.json (not found)",
        "OpenClaw openclaw.json": "/c/Users/kunan/.openclaw/openclaw.json (not found)",
        "Kiro mcp.json": "/c/Users/kunan/.kiro/settings/mcp.json (not found)",
        "Kiro default agent": "/c/Users/kunan/.kiro/agents/default.json (not found)",
        "Zed settings.json": "/c/Users/kunan/.config/zed/settings.json (not found)"
      },
      "configs": [
        {
          "name": "Codex config.toml",
          "path": "/c/Users/kunan/.codex/config.toml",
          "exists": true,
          "content": null
        },
        {
          "name": "opencode.json (global)",
          "path": "/c/Users/kunan/.config/opencode/opencode.json",
          "exists": true,
          "content": null
        }
      ],
      "warnings": [],
      "details": []
    },
    "7. Hook Validation": {
      "checks": [
        {
          "pass": true,
          "label": "PreToolUse registered"
        },
        {
          "pass": true,
          "label": "PostToolUse registered"
        },
        {
          "pass": true,
          "label": "PreCompact registered"
        },
        {
          "pass": true,
          "label": "SessionStart registered"
        }
      ],
      "info": {},
      "configs": [],
      "warnings": [],
      "details": []
    },
    "8. SQLite / FTS5 Test": {
      "checks": [
        {
          "pass": false,
          "label": "FTS5 in-memory test"
        }
      ],
      "info": {},
      "configs": [],
      "warnings": [],
      "details": []
    },
    "9. Executor Test": {
      "checks": [
        {
          "pass": true,
          "label": "node subprocess spawn"
        },
        {
          "pass": true,
          "label": "bash subprocess spawn"
        }
      ],
      "info": {},
      "configs": [],
      "warnings": [],
      "details": []
    },
    "10. Process Check": {
      "checks": [],
      "info": {
        "Running context-mode processes": "0"
      },
      "configs": [],
      "warnings": [],
      "details": []
    },
    "12. Environment Variables": {
      "checks": [],
      "info": {
        "TMPDIR": "unset",
        "TEMP": "/tmp",
        "TMP": "/tmp",
        "NODE_OPTIONS": "unset",
        "NODE_PATH": "C:/Users/kunan/.cache/opencode/packages/context-mode/node_modules/context-mode/node_modules:C:/Users/kunan/.cache/opencode/packages/context-mode/node_modules/context-mode/node_modules:",
        "NODE_EXTRA_CA_CERTS": "unset",
        "SSL_CERT_FILE": "unset",
        "CURL_CA_BUNDLE": "unset",
        "SSH_AUTH_SOCK": "unset",
        "CONTEXT_MODE_SESSION_SUFFIX": "unset",
        "CONTEXT_MODE_NODE": "unset"
      },
      "configs": [],
      "warnings": [],
      "details": []
    },
    "13. Hook Execution": {
      "checks": [
        {
          "pass": false,
          "label": "PreToolUse denies WebFetch"
        },
        {
          "pass": true,
          "label": "PreToolUse passes Write tool through"
        },
        {
          "pass": true,
          "label": "SessionStart injects routing context"
        }
      ],
      "info": {},
      "configs": [],
      "warnings": [],
      "details": []
    },
    "14. MCP Server Startup": {
      "checks": [
        {
          "pass": false,
          "label": "Server entry + deps resolve"
        }
      ],
      "info": {},
      "configs": [],
      "warnings": [],
      "details": []
    },
    "15. SQLite Concurrency": {
      "checks": [
        {
          "pass": false,
          "label": "Session DB uses WAL mode"
        },
        {
          "pass": true,
          "label": "No oversized WAL journals (>1MB)"
        },
        {
          "pass": true,
          "label": "No orphaned -shm files"
        },
        {
          "pass": false,
          "label": "Concurrent SQLite writes (3 conns × 30)"
        }
      ],
      "info": {},
      "configs": [],
      "warnings": [],
      "details": []
    },
    "16. Adapter Validation": {
      "checks": [
        {
          "pass": false,
          "label": "Adapter validation passes"
        }
      ],
      "info": {
        "Validated adapter": "Claude Code"
      },
      "configs": [],
      "warnings": [],
      "details": []
    },
    "17. Sandbox Environment": {
      "checks": [
        {
          "pass": false,
          "label": "System CA certificates found"
        },
        {
          "pass": true,
          "label": "Temp dir writable"
        },
        {
          "pass": true,
          "label": "Env denylist strips dangerous vars"
        }
      ],
      "info": {
        "Effective temp dir": "/tmp"
      },
      "configs": [],
      "warnings": [],
      "details": []
    },
    "18. Network / TLS": {
      "checks": [
        {
          "pass": true,
          "label": "HTTPS to npm registry"
        },
        {
          "pass": true,
          "label": "Temp dir >100MB free"
        }
      ],
      "info": {},
      "configs": [],
      "warnings": [],
      "details": []
    }
  },
  "summary": {
    "pass": 20,
    "fail": 9,
    "warnings": 0,
    "total": 29
  }
}

Exact prompt that triggered the bug (REQUIRED)

6. 去互联网上搜索下(主要在huggingface ModelScope等网站)搜索下目前有没有基于qwen 3.8 27B在我当前环境下(主要看模型尺寸),优化能力的新版本微调模型?

Full error output (REQUIRED)

Failed to fetch https://github.com/RaymondHuang210129/llama.cpp-adaptive-kv-streaming: C:\Users\kunan\.cache\opencode\packages\context-mode@latest\node_modules\turndown-plugin-gfm\lib\turndown-plugin-gfm.cjs.js:100
  var parentNode = tr.parentNode;
                      ^

TypeError: Cannot read properties of undefined (reading 'parentNode')
    at isHeadingRow (C:\Users\kunan\.cache\opencode\packages\context-mode@latest\node_modules\turndown-plugin-gfm\lib\turndown-plugin-gfm.cjs.js:100:23)
    at Object.filter (C:\Users\kunan\.cache\opencode\packages\context-mode@latest\node_modules\turndown-plugin-gfm\lib\turndown-plugin-gfm.cjs.js:77:41)
    at filterValue (C:\Users\kunan\.cache\opencode\packages\context-mode@latest\node_modules\turndown\lib\turndown.cjs.js:315:16)
    at findRule (C:\Users\kunan\.cache\opencode\packages\context-mode@latest\node_modules\turndown\lib\turndown.cjs.js:304:9)
    at Rules.forNode (C:\Users\kunan\.cache\opencode\packages\context-mode@latest\node_modules\turndown\lib\turndown.cjs.js:292:16)
    at TurndownService.replacementForNode (C:\Users\kunan\.cache\opencode\packages\context-mode@latest\node_modules\turndown\lib\turndown.cjs.js:738:25)
    at C:\Users\kunan\.cache\opencode\packages\context-mode@latest\node_modules\turndown\lib\turndown.cjs.js:705:40
    at NodeList.reduce (<anonymous>)
    at TurndownService.process (C:\Users\kunan\.cache\opencode\packages\context-mode@latest\node_modules\turndown\lib\turndown.cjs.js:699:17)
    at TurndownService.replacementForNode (C:\Users\kunan\.cache\opencode\packages\context-mode@latest\node_modules\turndown\lib\turndown.cjs.js:739:25)

Node.js v24.18.1

Steps to reproduce (REQUIRED)

  1. Install context-mode 1.0.169 (npm latest), plugin: ["context-mode"] in opencode.json
  2. Fetch any URL whose HTML contains an empty table, e.g. GitHub repo pages render empty markdown tables as
  3. Minimal repro: call ctx_fetch_and_index on any page containing
    — turndown 7.2.4 + turndown-plugin-gfm 1.0.2 throws TypeError, the whole fetch fails
  4. Control: without the gfm plugin,
    converts fine

What have you tried to fix it?

Pre-submission checklist

  • I have run the debug script and pasted the output above
  • I am using the latest version of context-mode
  • I have searched existing issues for duplicates
  • I have included steps to reproduce the issue

Operating System

Windows (Git Bash)

JS Runtime

Node v24.18.1

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions