Skip to content

[Bug] Monaco Editor always set up Native environment instead of Web environment on load. #4402

Closed

Description

@sonswift

Reproducible in vscode.dev or in VS Code Desktop?

  • Not reproducible in vscode.dev or VS Code Desktop

Reproducible in the monaco editor playground?

Monaco Editor Playground Link

No response

Monaco Editor Playground Code

No response

Reproduction Steps

No response

Actual (Problematic) Behavior

Hello, my application is broken after updating to version 0.46.0. I found the problem in platform.js always setup Native environment and attempt to get the value of undefined nodeProcess.env although I use monaco-editor with web environment (See attachment below)

Environment:
Electron: 26.0.0
React: 18.2.0
monaco-editor: 0.46.0
@monaco-editor/react: 4.5.2

CleanShot 2024-02-27 at 12 02 58@2x

Has anyone encountered a similar issue or found any solutions for this problem?
Thanks.

Expected Behavior

Please proceed to check as in version 0.45.0, where the web environment will be prioritized for examination first, or check if the value of nodeProcess.env is different from null and undefined.

Additional Context

No response

Activity

  1. jkorrek commented on Feb 29, 2024

    @jkorrek

    Facing the same issue, only solution for me is, to switch back to version 0.45.0.

    I am using webpack (with monaco-editor-webpack-plugin) to build web app and have to provide/polyfill "process" for another library. This messes up the platform detection & break clipboard paste functionality.

  2. j4k0xb commented on Mar 7, 2024

    @j4k0xb

    Same issue here, it was introduced in microsoft/vscode#200935

    or check if the value of nodeProcess.env is different from null and undefined

    it's also often polyfilled:
    image

    kkocdko (@kkocdko) could you please test if that works as expected in node/electron/browsers and make a new PR?

    - if (typeof nodeProcess === 'object') {
    + if (typeof nodeProcess?.versions?.node === 'string') {
  3. added a commit that references this issue on Mar 14, 2024
    3170112
  4. added
    bug
    on Mar 14, 2024
  5. added a commit that references this issue on Mar 14, 2024
    a5dd9d0
  6. added
    verification-steps-needed
    on Mar 27, 2024
  7. TylerLeonhardt commented on Mar 27, 2024

    @TylerLeonhardt
    Member

    Benjamin Pasero (@bpasero) can you provide some verification steps

  8. added
    debt
    and removed
    bug
    verification-steps-needed
    on Mar 27, 2024
  9. DanielRose commented on Apr 4, 2024

    @DanielRose

    This is still broken in 0.47.0. Verification has already been described:

    1. Create a browser app using monaco-editor
    2. Add a process polyfill, ex. in webpack.config.js: plugins: [ new webpack.ProvidePlugin({ process: 'process/browser' }) ]

    Clipboard copy/paste does not work as long as the polyfill exists.

    The linked commit would fix the issue, but it is not part of the 0.47.0 release.

  10. j4k0xb commented on Apr 4, 2024

    @j4k0xb

    The linked commit would fix the issue, but it is not part of the 0.47.0 release

    afaik monaco uses the latest vscode release, gotta wait for the next one
    or use the 0.48.0-dev versions for now

  11. DanielRose commented on May 22, 2024

    @DanielRose

    This bug was fixed, as least in our case, in 0.48.0

  12. locked and limited conversation to collaborators on Aug 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

debt

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions