Files
Project-Thoth/codex/chatgpt-capture-mvp/debugging/0007-resolve-connector-runtime.md
T

4.4 KiB
Raw Blame History

Work Order: Resolve connectorRuntime Module-Loading Regression

Current defect

The browser extension no longer creates a Markdown file in Downloads.

The extension console reports:

chrome-extension://.../connectorRuntime.js:1
Uncaught SyntaxError: Cannot use import statement outside a module

A separate page-level error also appears:

QuotaExceededError: Failed to execute 'setItem' on 'Storage':
Setting the value of
'cache/user-JY5yPfTiyFSprhKcrYXMA2gG/9e03f04b-55ee-4773-bb7b-47df25276387/system-connectors'
exceeded the quota.

Treat the QuotaExceededError as originating from the ChatGPT application unless repository evidence shows that the extension interacts with that storage key.

Objective

Restore the extension to the point where invoking capture reliably creates a Markdown file in the browser's Downloads location.

Required investigation

  1. Identify where connectorRuntime.js is loaded.

  2. Identify the import statement or statements causing the parse failure.

  3. Determine whether connectorRuntime.js is intended to be:

    • an ES module,
    • a bundled traditional script, or
    • imported by another module.
  4. Compare the current loading configuration with the last working implementation or repository history, where available.

  5. Determine whether the regression was introduced by:

    • adding an import statement to a non-module content script,
    • changing the manifest entry,
    • changing script injection logic,
    • moving code without updating module boundaries, or
    • failing to include the file in the build/bundle process.

Constraints

  • Make the smallest change necessary to restore the intended module-loading behavior.
  • Do not redesign the DOM extractor.
  • Do not change conversation-selection logic.
  • Do not modify Markdown normalization except where directly required by the module-loading repair.
  • Do not suppress the syntax error without addressing its cause.
  • Do not treat the ChatGPT QuotaExceededError as the extension root cause without evidence.
  • Preserve Manifest V3 compatibility.

Possible correction paths

Evaluate the repository and choose the correction consistent with the existing architecture. Possible approaches include:

Module-based loading

If connectorRuntime.js is intended to be an ES module, ensure it is loaded through a supported module mechanism.

For an extension service worker, this may require:

{
  "background": {
    "service_worker": "background.js",
    "type": "module"
  }
}

For a page or extension HTML document, this may require:

<script type="module" src="connectorRuntime.js"></script>

Do not assume that declaring a content script as a module is supported in the same way. Verify how the file is being executed.

Bundled or non-module loading

If connectorRuntime.js is a content script or injected traditional script, remove direct runtime import syntax by using the repository's intended bundling process or by restoring the prior dependency-loading pattern.

Do not simply concatenate files unless that is already the projects build design.

Dynamic import

Use import() only if it is valid in the execution context and consistent with the extension architecture. Do not use it merely to hide a structural module problem.

Diagnostics

Add or retain narrowly scoped diagnostic logging around:

[Thoth] connector runtime loaded
[Thoth] capture requested
[Thoth] extraction completed
[Thoth] markdown generated
[Thoth] download requested
[Thoth] download completed: <download ID>

Errors should be logged with the failed stage and exception.

Acceptance criteria

  1. The extension loads without:
Cannot use import statement outside a module
  1. Clicking the capture action reaches connectorRuntime.js.

  2. The extension creates a .md file in Downloads.

  3. The resulting file is non-empty.

  4. The extension console contains no uncaught extension-originated exception during capture.

  5. The ChatGPT page-level QuotaExceededError, if still present, does not prevent extension capture.

  6. Document:

    • the root cause,
    • the file or manifest entry responsible,
    • the corrective change,
    • why the selected module-loading approach is correct,
    • and the verification performed.

Out of scope

  • Improving DOM selectors
  • Solving missing historical turns
  • Improving table conversion
  • Improving citation conversion
  • Changing the conversation intermediate model
  • General refactoring