microsoft / microsoft/monaco-editor

[Bug] TypeError: "e is not iterable" in JSON worker initialization with monaco-editor@0.55.x and webpack-plugin@7.1.0

Open
#5,144 0 comments 1 reaction 1 assignee View on GitHub

@hediet is already working on this.

Since Dec 15, 2025.

Dominant language
JavaScript
Stars
46.8k
Forks
4.1k
Avg merge
17h 58m
Merged PRs (30d)
1

Description

Reproducible in monaco-editor-playground?

No - this is specific to the webpack plugin bundling setup.

Version
  • monaco-editor: 0.55.1
  • monaco-editor-webpack-plugin: 7.1.0
  • @monaco-editor/react: 4.7.0
  • Next.js: 15.2.4
Browser and OS info

Chrome (latest), macOS

Description

When using monaco-editor 0.55.x with the webpack plugin to load the JSON language, the JSON worker fails to initialize with a "TypeError: e is not iterable" error.

Steps to reproduce
  1. Create a Next.js project with monaco-editor and the webpack plugin
  2. Configure next.config.mjs:
import MonacoWebpackPlugin from 'monaco-editor-webpack-plugin';

const nextConfig = {
    webpack: (config, { isServer }) => {
        if (!isServer) {
            config.plugins.push(
                new MonacoWebpackPlugin({
                    languages: ['json', 'plaintext'],
                    filename: 'static/[name].worker.js',
                })
            );
        }
        return config;
    },
};

export default nextConfig;
  1. Configure monaco loader to use the installed monaco-editor:
import { loader } from '@monaco-editor/react';

const monaco = await import('monaco-editor');
loader.config({ monaco });
  1. Render a Monaco Editor with language="json"
  2. Navigate to the page in Chrome
Actual behavior

The JSON worker fails to initialize with the following error:

json.worker.js:1 Uncaught TypeError: e is not iterable
    at json.worker.js:1:77543
    at rJ.initialize (json.worker.js:1:77630)
    at rJ._handleMessage (json.worker.js:1:76640)
    at Object.handleMessage (json.worker.js:1:76478)
    at rz._handleRequestMessage (json.worker.js:1:75261)
    at rz._handleMessage (json.worker.js:1:74713)
    at rz.handleMessage (json.worker.js:1:74601)
    at rJ.onmessage (json.worker.js:1:76570)
    at globalThis.onmessage (json.worker.js:1:253773)
Expected behavior

The JSON worker should initialize successfully and provide JSON language features.

Root Cause Analysis

The error occurs in the vscode-json-languageservice when the configure() method tries to iterate over settings. Looking at the source:

In jsonLanguageService.ts:

configure: (settings) => {
    jsonSchemaService.clearExternalSchemas();
    settings.schemas?.forEach(jsonSchemaService.registerExternalSchema.bind(jsonSchemaService));
    // ...
}

In jsonSchemaService.ts setSchemaContributions():

for (let schemaAssociation of schemaAssociations) { ... }

The worker receives initialization data via workerManager.js:

createData: {
    languageSettings: this._defaults.diagnosticsOptions,
    languageId: this._defaults.languageId,
    enableSchemaRequest: this._defaults.diagnosticsOptions.enableSchemaRequest
}

Suspected cause: Monaco 0.55.0 introduced breaking namespace changes (moving languages.json to json). The webpack plugin may be passing initialization data in an incompatible format, or there's a mismatch in how the bundled vscode-json-languageservice expects to receive configuration.

Workaround

Downgrading to monaco-editor@0.52.0 resolves the issue:

npm install monaco-editor@0.52.0
Additional context
  • The error does not occur with monaco-editor 0.52.0
  • The webpack plugin repository was archived in Nov 2023 and moved into the main monaco-editor repo
  • Related changelog entry in 0.55.0: "Moves nested namespaces (languages.css, languages.html, languages.json, languages.typescript) to top level namespaces"

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.