Skip to content

SRVOCF-1007: Fix Monaco editor errors when loading JavaScript files - #34

Open
twoGiants wants to merge 1 commit into
openshift:masterfrom
twoGiants:SRVOCF-1007-edit-page-shows-error-after-a-function-is-loaded
Open

SRVOCF-1007: Fix Monaco editor errors when loading JavaScript files#34
twoGiants wants to merge 1 commit into
openshift:masterfrom
twoGiants:SRVOCF-1007-edit-page-shows-error-after-a-function-is-loaded

Conversation

@twoGiants

Copy link
Copy Markdown

Summary

  • 🐛 Fix "Unexpected usage" errors on the edit page when opening JavaScript or TypeScript function files. The OCP console does not bundle Monaco's TypeScript worker, so setting language="javascript" caused loadForeignModule to fail. Calling setModeConfiguration({}) in the editor's beforeMount callback disables all worker-dependent features while preserving syntax highlighting.
  • 🧪 Add e2e regression test verifying the editor loads JS files without console errors or webpack overlay.
  • 📚 Add Jira bug template, regression test rule in TESTING.md, OCP console plugin inventory, and bug template references in README and AGILE.md.
  • 🔧 Add missing .pi/prompts symlinks and .pi-subagents to .gitignore.

Fixes SRVOCF-1007

Checklist

  • Updated docs/ARCHITECTURE.md (if there are relevant changes to our layered architecture)

Additional Info

The OCP console's MonacoWebpackPlugin is configured with languages: ['yaml', 'dockerfile', 'json', 'plaintext']. No other OCP console plugin uses CodeEditor with language="javascript" or language="typescript" (surveyed 25+ plugins, all use yaml, json, or plaintext). setModeConfiguration({}) is Monaco's public API for disabling worker-dependent features per language mode. Syntax highlighting uses the Monarch tokenizer, which runs synchronously on the main thread and is unaffected.

The OCP console bundles Monaco workers for editor, json, and yaml
only. When the edit page sets language="javascript", Monaco's TS
language service activates and tries to load ts.worker.js, which
does not exist. This causes "Unexpected usage" errors from
loadForeignModule, blocking the UI with a webpack error overlay.

Call setModeConfiguration({}) on javascriptDefaults and
typescriptDefaults in the editor's beforeMount callback. This
disables all worker-dependent features (diagnostics, completions,
hover) while preserving Monarch tokenizer syntax highlighting.

Also adds a Jira bug template, an e2e regression test, a
regression test rule in TESTING.md, and an OCP console plugin
inventory in the dynamic plugin reference.

Issue SRVOCF-1007
@openshift-ci-robot openshift-ci-robot added the jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. label Jul 29, 2026
@openshift-ci-robot

openshift-ci-robot commented Jul 29, 2026

Copy link
Copy Markdown

@twoGiants: This pull request references SRVOCF-1007 which is a valid jira issue.

Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the bug to target the "5.0.0" version, but no target version was set.

Details

In response to this:

Summary

  • 🐛 Fix "Unexpected usage" errors on the edit page when opening JavaScript or TypeScript function files. The OCP console does not bundle Monaco's TypeScript worker, so setting language="javascript" caused loadForeignModule to fail. Calling setModeConfiguration({}) in the editor's beforeMount callback disables all worker-dependent features while preserving syntax highlighting.
  • 🧪 Add e2e regression test verifying the editor loads JS files without console errors or webpack overlay.
  • 📚 Add Jira bug template, regression test rule in TESTING.md, OCP console plugin inventory, and bug template references in README and AGILE.md.
  • 🔧 Add missing .pi/prompts symlinks and .pi-subagents to .gitignore.

Fixes SRVOCF-1007

Checklist

  • Updated docs/ARCHITECTURE.md (if there are relevant changes to our layered architecture)

Additional Info

The OCP console's MonacoWebpackPlugin is configured with languages: ['yaml', 'dockerfile', 'json', 'plaintext']. No other OCP console plugin uses CodeEditor with language="javascript" or language="typescript" (surveyed 25+ plugins, all use yaml, json, or plaintext). setModeConfiguration({}) is Monaco's public API for disabling worker-dependent features per language mode. Syntax highlighting uses the Monarch tokenizer, which runs synchronously on the main thread and is unaffected.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

@openshift-ci

openshift-ci Bot commented Jul 29, 2026

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: twoGiants

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-ci openshift-ci Bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jul 29, 2026

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR addresses SRVOCF-1007 by preventing Monaco worker related runtime errors when opening JavaScript and TypeScript files in the function edit page, and it adds supporting documentation and an e2e regression test to prevent recurrence.

Changes:

  • Disable worker-dependent Monaco JS/TS features during editor initialization while keeping syntax highlighting.
  • Add a Playwright e2e regression test for loading and switching JavaScript files without triggering the error overlay.
  • Add a Jira bug template and update contributor documentation and ignores to reflect the new workflow.

Reviewed changes

Copilot reviewed 9 out of 10 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
src/pages/function-edit/FunctionEditPage.tsx Configures Monaco JS/TS mode to avoid worker loading errors on the edit page.
e2e/use-cases/edit/edit-javascript-function.test.ts Adds an e2e regression test covering JS editing without the prior runtime errors.
docs/TESTING.md Adds an explicit rule that bug fixes must include a regression test.
docs/templates/jira-bug-template.md Introduces a standardized Jira bug filing template with regression test guidance.
README.md Links the new Jira bug template from the project templates table.
docs/AGILE.md Documents bugs as a first-class Jira issue type and links the bug template.
docs/references/ocp-dynamic-plugin-reference.md Adds an inventory reference for OCP dynamic plugins.
.gitignore Ignores .pi-subagents artifacts.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +94 to +96
editorProps={{
beforeMount: (monaco: Monaco) => {
// SRVOCF-1007: the OCP console does not bundle Monaco's TS worker.
Comment on lines +9 to +11
const consoleErrors: string[] = [];
page.on('pageerror', (err) => consoleErrors.push(err.message));

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@twoGiants that seems like a reasonably addition to test coverage.

@@ -1,5 +1,6 @@
import { CodeEditor, DocumentTitle, ListPageHeader } from '@openshift-console/dynamic-plugin-sdk';
import type { Language } from '@patternfly/react-code-editor';
import type { Monaco } from '@monaco-editor/react';
@openshift-ci

openshift-ci Bot commented Jul 29, 2026

Copy link
Copy Markdown

@twoGiants: all tests passed!

Full PR test history. Your PR dashboard.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here.

@Cragsmann Cragsmann left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we want to include jira tickets in the code? (e2e name and comment in edit page)

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

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. jira/valid-reference Indicates that this PR references a valid Jira ticket of any type.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants