Skip to content

Electron 33 broken #978

Closed
Closed

Description

@danielweck

The latest NAN release works fine in Electron 32, but now fails with:

In file included from ../node_modules/nan/nan.h:3045:
../node_modules/nan/nan_scriptorigin.h:40:7: error: no matching constructor for initialization of 'v8::ScriptOrigin'
   40 |       v8::ScriptOrigin(v8::Isolate::GetCurrent()
      |       ^                ~~~~~~~~~~~~~~~~~~~~~~~~~
   41 |                    , name
      |                    ~~~~~~
   42 |                    , To<int32_t>(line).FromMaybe(0)) {}
../node_modules/nan/nan_scriptorigin.h:47:7: error: no matching constructor for initialization of 'v8::ScriptOrigin'
   47 |       v8::ScriptOrigin(v8::Isolate::GetCurrent()
      |       ^                ~~~~~~~~~~~~~~~~~~~~~~~~~
   48 |                    , name
      |                    ~~~~~~
   49 |                    , To<int32_t>(line).FromMaybe(0)
      |                    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   50 |                    , To<int32_t>(column).FromMaybe(0)) {}

../node_modules/nan/nan_scriptorigin.h:36:7: error: no matching constructor for initialization of 'v8::ScriptOrigin'
   36 |       v8::ScriptOrigin(v8::Isolate::GetCurrent(), name) {}
      |       ^                ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/qwe/Library/Caches/node-gyp/33.0.0/include/node/v8-message.h:64:13: note: candidate constructor not viable: no known conversion from 'Isolate *' to 'Local<Value>' for 1st argument
   64 |   V8_INLINE ScriptOrigin(Local<Value> resource_name,
      |             ^            ~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/qwe/Library/Caches/node-gyp/33.0.0/include/node/v8-message.h:62:17: note: candidate constructor (the implicit copy constructor) not viable: requires 1 argument, but 2 were provided
   62 | class V8_EXPORT ScriptOrigin {
      |                 ^~~~~~~~~~~~
/Users/qwe/Library/Caches/node-gyp/33.0.0/include/node/v8-message.h:62:17: note: candidate constructor (the implicit move constructor) not viable: requires 1 argument, but 2 were provided
   62 | class V8_EXPORT ScriptOrigin {
      |                 ^~~~~~~~~~~~

Activity

  1. danielweck commented on Oct 16, 2024

    @danielweck
    Author
  2. danielweck commented on Oct 16, 2024

    @danielweck
    Author
  3. agracio commented on Oct 16, 2024

    @agracio
    Contributor

    Electron 33 moved to v8 13.0 while Node.js main is currently on v8 12.9, perhaps someone can create a working fork that addresses the problem?
    Unless by some miracle Node.js moves to v8 13.0 for its v23 release I do not think nan will address the issue themselves.

  4. danielweck commented on Oct 16, 2024

    @danielweck
    Author
  5. agracio commented on Oct 16, 2024

    @agracio
    Contributor

    You should not ping nan maintainers as they have been quick to point out that they do not support and have no intention to support Electron in the future.

  6. danielweck commented on Oct 16, 2024

    @danielweck
    Author

    Apologies, I thought you were the NAN maintainer :) 👍 (very quick response indeed, thank you)

    Well, my workaround is to comment #include nan_scriptorigin.h in nan.h:

    nan/nan.h

    Line 3045 in f5921c7

    #include "nan_scriptorigin.h" // NOLINT(build/include)

    (I do this with sed from my package.json postinstall)

    Closing the issue now.

  7. kkoopa commented on Oct 16, 2024

    @kkoopa
    Collaborator

    It is probably this commit. 0151569 I will get around to it at some future time.

  8. agracio commented on Oct 16, 2024

    @agracio
    Contributor

    Thanks!

  9. agracio commented on Oct 16, 2024

    @agracio
    Contributor

    @danielweck could you share your package.json script with postinstall

  10. kkoopa commented on Oct 16, 2024

    @kkoopa
    Collaborator

    And can someone with Electron 33 confirm that applying 0151569 resolves the issue?

  11. agracio commented on Oct 16, 2024

    @agracio
    Contributor

    Will do but give me about 30+ minutes.

  12. danielweck commented on Oct 16, 2024

    @danielweck
    Author

    @danielweck could you share your package.json script with postinstall

    Not pretty, quick and dirty, but works in MacOS and Linux:

    "postinstall": "sed 's/^#include .nan_scriptorigin\\.h./\\/\\/ #include nan_scriptorigin.h/' ./node_modules/nan/nan.h > ./node_modules/nan/nan.h.new && mv ./node_modules/nan/nan.h.new ./node_modules/nan/nan.h"

  13. agracio commented on Oct 16, 2024

    @agracio
    Contributor

    And can someone with Electron 33 confirm that applying 0151569 resolves the issue?

    It absolutely does, tested Electron 29, 30, 31, 32 and 33 that are supported by nan 2.22.

  14. agracio commented on Oct 17, 2024

    @agracio
    Contributor

    @kkoopa So is it just a issue of merging that commit and everything will be working?

  15. added a commit that references this issue on Jan 30, 2025
  16. ayZagen commented on Feb 9, 2025

    @ayZagen

    @danielweck this issue is still valid and should be open until a fix is landed

  17. agracio commented on Feb 28, 2025

    @agracio
    Contributor

    The issue is not present in nan v2.22.2 tested with electron 29-34 as well as 35 beta and latest 36 nightly.

  18. oalfroukh commented on Mar 2, 2025

    @oalfroukh

    Apologies, I thought you were the NAN maintainer :) 👍 (very quick response indeed, thank you)

    Well, my workaround is to comment #include nan_scriptorigin.h in nan.h:

    nan/nan.h

    Line 3045 in f5921c7

    #include "nan_scriptorigin.h" // NOLINT(build/include)
    (I do this with sed from my package.json postinstall)

    Closing the issue now.

    Hi @danielweck
    But this postinstall will not work fine in case using nan by subDependencies, so I think this issue should be reopened as needs a fix...
    Anyone can take a look at it, please?

    EDIT:
    The issue is fixed on nan v2.22.2 so overrides the version to the latest version that's released 4 days ago(`v2.22.2) will fix the issue.

  19. agracio commented on Mar 2, 2025

    @agracio
    Contributor

    While the issue is solved in nan v2.22.2 postinstall overrides can be easily applied for sub dependencies.
    Here is a sample script from my repo:

    updatenan.js

    const spawn = require('child_process').spawn
    const existsSync = require('fs').existsSync
    const nanPath = existsSync('./node_modules/nan/nan.h') ? './node_modules/nan/nan.h' : '../nan/nan.h'
    
    if(existsSync(nanPath)){
        if (process.platform === 'win32') {
            spawn('powershell', ['-Command', `(Get-Content -Raw ${nanPath}) -replace '#include \"nan_scriptorigin.h\"', '// #include \"nan_scriptorigin.h\"' | Out-File -Encoding Utf8 ${nanPath}`], { stdio: 'inherit' })
        } else {
            spawn('sed', ['-i', '-e', 's/^#include .nan_scriptorigin\\.h./\\/\\/ #include nan_scriptorigin.h/', nanPath], { stdio: 'inherit' })
        }
    
    }
  20. oalfroukh commented on Mar 3, 2025

    @oalfroukh

    While the issue is solved in nan v2.22.2 postinstall overrides can be easily applied for sub dependencies. Here is a sample script from my repo:

    updatenan.js

    const spawn = require('child_process').spawn
    const existsSync = require('fs').existsSync
    const nanPath = existsSync('./node_modules/nan/nan.h') ? './node_modules/nan/nan.h' : '../nan/nan.h'

    if(existsSync(nanPath)){
    if (process.platform === 'win32') {
    spawn('powershell', ['-Command', (Get-Content -Raw ${nanPath}) -replace '#include \"nan_scriptorigin.h\"', '// #include \"nan_scriptorigin.h\"' | Out-File -Encoding Utf8 ${nanPath}], { stdio: 'inherit' })
    } else {
    spawn('sed', ['-i', '-e', 's/^#include .nan_scriptorigin\.h./\/\/ #include nan_scriptorigin.h/', nanPath], { stdio: 'inherit' })
    }

    }

    Also just adding overrides to the package.json should fix the issue for sub dependencies instead of using scripts

    ,
      "overrides": {
        "nan": "2.22.2"
      }
    
  21. agracio commented on Mar 3, 2025

    @agracio
    Contributor

    I removed that script from my repo since the release of nan v2.22.2 just wanted to show a PoC of install/postinstall script that works for sub dependencies. Cannot even take a credit for it as it was a PR from one of the repo contributors.

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions