Skip to content
This repository has been archived by the owner on Dec 15, 2022. It is now read-only.

Fails to build from source on Electron versions higher than 12 #242

Open
LoganDark opened this issue Sep 27, 2021 · 5 comments
Open

Fails to build from source on Electron versions higher than 12 #242

LoganDark opened this issue Sep 27, 2021 · 5 comments

Comments

@LoganDark
Copy link

LoganDark commented Sep 27, 2021

Description

@atom/watcher fails to build with Electron versions higher than 12

Steps to Reproduce

  1. Build from source using Electron 13+
  2. node_modules\@atom\watcher\src\nan\functional_callback.cpp(17,35): error C2039: 'Contents': is not a member of 'v8::ArrayBuffer' [node_modules\@atom\watcher\build\watcher.vcxproj]
    C:\Users\LoganDark\.electron-gyp\14.0.0-beta.21\include\node\v8.h(5353): message : see declaration of 'v8::ArrayBuffer' [node_modules\@atom\watcher\build\watcher.vcxproj]
    node_modules\@atom\watcher\src\nan\functional_callback.cpp(17,43): error C2061: syntax error: identifier 'Contents' [node_modules\@atom\watcher\build\watcher.vcxproj]
    node_modules\@atom\watcher\src\nan\functional_callback.cpp(27,3): error C2065: 'Contents': undeclared identifier [node_modules\@atom\watcher\build\watcher.vcxproj]
    node_modules\@atom\watcher\src\nan\functional_callback.cpp(27,12): error C2146: syntax error: missing ';' before identifier 'cb_contents' [node_modules\@atom\watcher\build\watcher.vcxproj]
    node_modules\@atom\watcher\src\nan\functional_callback.cpp(27,12): error C2065: 'cb_contents': undeclared identifier [node_modules\@atom\watcher\build\watcher.vcxproj]
    node_modules\@atom\watcher\src\nan\functional_callback.cpp(27,36): error C2039: 'GetContents': is not a member of 'v8::ArrayBuffer' [node_modules\@atom\watcher\build\watcher.vcxproj]
    C:\Users\LoganDark\.electron-gyp\14.0.0-beta.21\include\node\v8.h(5353): message : see declaration of 'v8::ArrayBuffer' [node_modules\@atom\watcher\build\watcher.vcxproj]
    node_modules\@atom\watcher\src\nan\functional_callback.cpp(29,43): error C2065: 'cb_contents': undeclared identifier [node_modules\@atom\watcher\build\watcher.vcxproj]
    node_modules\@atom\watcher\src\nan\functional_callback.cpp(30,3): error C2065: 'cb_contents': undeclared identifier [node_modules\@atom\watcher\build\watcher.vcxproj]
    node_modules\@atom\watcher\src\nan\functional_callback.cpp(32,53): error C3536: 'payload': cannot be used before it is initialized [node_modules\@atom\watcher\build\watcher.vcxproj]
    node_modules\@atom\watcher\src\nan\functional_callback.cpp(32,45): error C2100: illegal indirection [node_modules\@atom\watcher\build\watcher.vcxproj]
    node_modules\@atom\watcher\src\nan\functional_callback.cpp(32,53): warning C4312: 'reinterpret_cast': conversion from 'int' to 'FnCallback *' of greater size [node_modules\@atom\watcher\build\watcher.vcxproj]
    node_modules\@atom\watcher\src\nan\functional_callback.cpp(34,17): error C2541: 'delete': cannot delete objects that are not pointers [node_modules\@atom\watcher\build\watcher.vcxproj]
    node_modules\@atom\watcher\src\nan\functional_callback.cpp(45,95): error C2661: 'v8::ArrayBuffer::New': no overloaded function takes 3 arguments [node_modules\@atom\watcher\build\watcher.vcxproj]
    

Expected behavior:

It builds

Actual behavior:

It doesn't

Reproduces how often:

Always

Versions

Node version: v16.7.0
npm version: v7.20.3
Windows 10 Home 2004 build 19041.928

Additional Information

https://docs.google.com/document/d/1sTc_jRL87Fu175Holm5SV0kajkseGl2r8ifGY76G35k/view

@LoganDark LoganDark changed the title Fails to build from source on node 16 Fails to build from source on Electron versions higher than 12 Sep 28, 2021
@george-thomas-hill
Copy link

I encounter the same problem in a different way.

I have been trying to get atom watcher to work with Electron via Electron Forge.

On a clean install of Ubuntu 20.04.3, I created an Electron Forge webpack starter app using npx create-electron-app my-new-app --template=webpack.

I then installed atom watcher using npm install @atom/watcher.

I then added, to main.js, the sample code here.

When I try to run it with npm start, I get the following:

georgehill@ubuntu:~/Desktop/GH/FF/test-atom-watcher/my-new-app$ npm start

> my-new-app@1.0.0 start
> electron-forge start

✔ Checking your system
✔ Locating Application
⠙ Preparing native dependencies: 0 / 1make: Entering directory '/home/georgehill/Desktop/GH/FF/test-atom-watcher/my-new-app/node_modules/@atom/watcher/build'
  CXX(target) Release/obj.target/watcher/src/binding.o
⠴ Preparing native dependencies: 0 / 1In file included from /home/georgehill/.electron-gyp/15.1.2/include/node/node.h:63,
                 from ../../../nan/nan.h:56,
                 from ../src/binding.cpp:2:
/home/georgehill/.electron-gyp/15.1.2/include/node/v8.h:1684:79: warning: ‘using ResolveCallback = class v8::MaybeLocal<v8::Module> (*)(class v8::Local<v8::Context>, class v8::Local<v8::String>, class v8::Local<v8::Module>)’ is deprecated: Use ResolveModuleCallback [-Wdeprecated-declarations]
 1684 |                                                       ResolveCallback callback);
      |                                                                               ^
/home/georgehill/.electron-gyp/15.1.2/include/node/v8.h:1666:9: note: declared here
 1666 |   using ResolveCallback V8_DEPRECATED("Use ResolveModuleCallback") =
      |         ^~~~~~~~~~~~~~~
/home/georgehill/.electron-gyp/15.1.2/include/node/v8.h:8724:51: warning: ‘using HostImportModuleDynamicallyCallback = class v8::MaybeLocal<v8::Promise> (*)(class v8::Local<v8::Context>, class v8::Local<v8::ScriptOrModule>, class v8::Local<v8::String>)’ is deprecated: Use HostImportModuleDynamicallyWithImportAssertionsCallback instead [-Wdeprecated-declarations]
 8724 |       HostImportModuleDynamicallyCallback callback);
      |                                                   ^
/home/georgehill/.electron-gyp/15.1.2/include/node/v8.h:7334:7: note: declared here
 7334 | using HostImportModuleDynamicallyCallback V8_DEPRECATED(
      |       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
⠧ Preparing native dependencies: 0 / 1In file included from ../src/binding.cpp:2:
../../../nan/nan.h: In function ‘void Nan::AsyncQueueWorker(Nan::AsyncWorker*)’:
../../../nan/nan.h:2294:62: warning: cast between incompatible function types from ‘void (*)(uv_work_t*)’ {aka ‘void (*)(uv_work_s*)’} to ‘uv_after_work_cb’ {aka ‘void (*)(uv_work_s*, int)’} [-Wcast-function-type]
 2294 |     , reinterpret_cast<uv_after_work_cb>(AsyncExecuteComplete)
      |                                                              ^
⠋ Preparing native dependencies: 0 / 1In file included from ../../../nan/nan.h:56,
                 from ../src/binding.cpp:2:
../src/binding.cpp: At global scope:
/home/georgehill/.electron-gyp/15.1.2/include/node/node.h:817:43: warning: cast between incompatible function types from ‘void (*)(v8::Local<v8::Object>)’ to ‘node::addon_register_func’ {aka ‘void (*)(v8::Local<v8::Object>, v8::Local<v8::Value>, void*)’} [-Wcast-function-type]
  817 |       (node::addon_register_func) (regfunc),                          \
      |                                           ^
/home/georgehill/.electron-gyp/15.1.2/include/node/node.h:851:3: note: in expansion of macro ‘NODE_MODULE_X’
  851 |   NODE_MODULE_X(modname, regfunc, NULL, 0)  // NOLINT (readability/null_usage)
      |   ^~~~~~~~~~~~~
../src/binding.cpp:217:1: note: in expansion of macro ‘NODE_MODULE’
  217 | NODE_MODULE(watcher, initialize);  // NOLINT
      | ^~~~~~~~~~~
⠦ Preparing native dependencies: 0 / 1  CXX(target) Release/obj.target/watcher/src/hub.o
⠏ Preparing native dependencies: 0 / 1In file included from /home/georgehill/.electron-gyp/15.1.2/include/node/node.h:63,
                 from ../../../nan/nan.h:56,
                 from ../src/hub.cpp:3:
/home/georgehill/.electron-gyp/15.1.2/include/node/v8.h:1684:79: warning: ‘using ResolveCallback = class v8::MaybeLocal<v8::Module> (*)(class v8::Local<v8::Context>, class v8::Local<v8::String>, class v8::Local<v8::Module>)’ is deprecated: Use ResolveModuleCallback [-Wdeprecated-declarations]
 1684 |                                                       ResolveCallback callback);
      |                                                                               ^
/home/georgehill/.electron-gyp/15.1.2/include/node/v8.h:1666:9: note: declared here
 1666 |   using ResolveCallback V8_DEPRECATED("Use ResolveModuleCallback") =
      |         ^~~~~~~~~~~~~~~
⠋ Preparing native dependencies: 0 / 1/home/georgehill/.electron-gyp/15.1.2/include/node/v8.h:8724:51: warning: ‘using HostImportModuleDynamicallyCallback = class v8::MaybeLocal<v8::Promise> (*)(class v8::Local<v8::Context>, class v8::Local<v8::ScriptOrModule>, class v8::Local<v8::String>)’ is deprecated: Use HostImportModuleDynamicallyWithImportAssertionsCallback instead [-Wdeprecated-declarations]
 8724 |       HostImportModuleDynamicallyCallback callback);
      |                                                   ^
/home/georgehill/.electron-gyp/15.1.2/include/node/v8.h:7334:7: note: declared here
 7334 | using HostImportModuleDynamicallyCallback V8_DEPRECATED(
      |       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
⠙ Preparing native dependencies: 0 / 1In file included from ../src/hub.cpp:3:
../../../nan/nan.h: In function ‘void Nan::AsyncQueueWorker(Nan::AsyncWorker*)’:
../../../nan/nan.h:2294:62: warning: cast between incompatible function types from ‘void (*)(uv_work_t*)’ {aka ‘void (*)(uv_work_s*)’} to ‘uv_after_work_cb’ {aka ‘void (*)(uv_work_s*, int)’} [-Wcast-function-type]
 2294 |     , reinterpret_cast<uv_after_work_cb>(AsyncExecuteComplete)
      |                                                              ^
⠴ Preparing native dependencies: 0 / 1../src/hub.cpp: In member function ‘void Hub::handle_events_from(Thread&)’:
../src/hub.cpp:216:117: warning: ignoring return value of ‘v8::Maybe<bool> v8::Object::Set(v8::Local<v8::Context>, v8::Local<v8::Value>, v8::Local<v8::Value>)’, declared with attribute warn_unused_result [-Wunused-result]
  216 |         Nan::New<String>("action").ToLocalChecked(), Nan::New<Number>(static_cast<int>(fs->get_filesystem_action())));
      |                                                                                                                     ^
In file included from /home/georgehill/.electron-gyp/15.1.2/include/node/node.h:63,
                 from ../../../nan/nan.h:56,
                 from ../src/hub.cpp:3:
/home/georgehill/.electron-gyp/15.1.2/include/node/v8.h:3964:37: note: declared here
 3964 |   V8_WARN_UNUSED_RESULT Maybe<bool> Set(Local<Context> context,
      |                                     ^~~
../src/hub.cpp:218:108: warning: ignoring return value of ‘v8::Maybe<bool> v8::Object::Set(v8::Local<v8::Context>, v8::Local<v8::Value>, v8::Local<v8::Value>)’, declared with attribute warn_unused_result [-Wunused-result]
  218 |         Nan::New<String>("kind").ToLocalChecked(), Nan::New<Number>(static_cast<int>(fs->get_entry_kind())));
      |                                                                                                            ^
In file included from /home/georgehill/.electron-gyp/15.1.2/include/node/node.h:63,
                 from ../../../nan/nan.h:56,
                 from ../src/hub.cpp:3:
/home/georgehill/.electron-gyp/15.1.2/include/node/v8.h:3964:37: note: declared here
 3964 |   V8_WARN_UNUSED_RESULT Maybe<bool> Set(Local<Context> context,
      |                                     ^~~
../src/hub.cpp:220:108: warning: ignoring return value of ‘v8::Maybe<bool> v8::Object::Set(v8::Local<v8::Context>, v8::Local<v8::Value>, v8::Local<v8::Value>)’, declared with attribute warn_unused_result [-Wunused-result]
  220 |         Nan::New<String>("oldPath").ToLocalChecked(), Nan::New<String>(fs->get_old_path()).ToLocalChecked());
      |                                                                                                            ^
In file included from /home/georgehill/.electron-gyp/15.1.2/include/node/node.h:63,
                 from ../../../nan/nan.h:56,
                 from ../src/hub.cpp:3:
/home/georgehill/.electron-gyp/15.1.2/include/node/v8.h:3964:37: note: declared here
 3964 |   V8_WARN_UNUSED_RESULT Maybe<bool> Set(Local<Context> context,
      |                                     ^~~
../src/hub.cpp:221:122: warning: ignoring return value of ‘v8::Maybe<bool> v8::Object::Set(v8::Local<v8::Context>, v8::Local<v8::Value>, v8::Local<v8::Value>)’, declared with attribute warn_unused_result [-Wunused-result]
  221 |       js_event->Set(context, Nan::New<String>("path").ToLocalChecked(), Nan::New<String>(fs->get_path()).ToLocalChecked());
      |                                                                                                                          ^
In file included from /home/georgehill/.electron-gyp/15.1.2/include/node/node.h:63,
                 from ../../../nan/nan.h:56,
                 from ../src/hub.cpp:3:
/home/georgehill/.electron-gyp/15.1.2/include/node/v8.h:3964:37: note: declared here
 3964 |   V8_WARN_UNUSED_RESULT Maybe<bool> Set(Local<Context> context,
      |                                     ^~~
../src/hub.cpp:316:45: warning: ignoring return value of ‘v8::Maybe<bool> v8::Object::Set(v8::Local<v8::Context>, uint32_t, v8::Local<v8::Value>)’, declared with attribute warn_unused_result [-Wunused-result]
  316 |       js_array->Set(context, index, js_event);
      |                                             ^
In file included from /home/georgehill/.electron-gyp/15.1.2/include/node/node.h:63,
                 from ../../../nan/nan.h:56,
                 from ../src/hub.cpp:3:
/home/georgehill/.electron-gyp/15.1.2/include/node/v8.h:3967:37: note: declared here
 3967 |   V8_WARN_UNUSED_RESULT Maybe<bool> Set(Local<Context> context, uint32_t index,
      |                                     ^~~
⠏ Preparing native dependencies: 0 / 1  CXX(target) Release/obj.target/watcher/src/log.o
⠦ Preparing native dependencies: 0 / 1  CXX(target) Release/obj.target/watcher/src/errable.o
⠙ Preparing native dependencies: 0 / 1  CXX(target) Release/obj.target/watcher/src/queue.o
⠧ Preparing native dependencies: 0 / 1  CXX(target) Release/obj.target/watcher/src/lock.o
⠇ Preparing native dependencies: 0 / 1  CXX(target) Release/obj.target/watcher/src/message.o
⠴ Preparing native dependencies: 0 / 1  CXX(target) Release/obj.target/watcher/src/message_buffer.o
⠋ Preparing native dependencies: 0 / 1  CXX(target) Release/obj.target/watcher/src/thread_starter.o
⠴ Preparing native dependencies: 0 / 1  CXX(target) Release/obj.target/watcher/src/thread.o
⠦ Preparing native dependencies: 0 / 1  CXX(target) Release/obj.target/watcher/src/status.o
⠙ Preparing native dependencies: 0 / 1  CXX(target) Release/obj.target/watcher/src/worker/worker_thread.o
⠇ Preparing native dependencies: 0 / 1  CXX(target) Release/obj.target/watcher/src/worker/recent_file_cache.o
⠹ Preparing native dependencies: 0 / 1  CXX(target) Release/obj.target/watcher/src/polling/directory_record.o
⠼ Preparing native dependencies: 0 / 1  CXX(target) Release/obj.target/watcher/src/polling/polled_root.o
⠙ Preparing native dependencies: 0 / 1  CXX(target) Release/obj.target/watcher/src/polling/polling_iterator.o
⠇ Preparing native dependencies: 0 / 1  CXX(target) Release/obj.target/watcher/src/polling/polling_thread.o
⠹ Preparing native dependencies: 0 / 1  CXX(target) Release/obj.target/watcher/src/helper/libuv.o
                                        CXX(target) Release/obj.target/watcher/src/nan/async_callback.o
⠏ Preparing native dependencies: 0 / 1In file included from /home/georgehill/.electron-gyp/15.1.2/include/node/node.h:63,
                 from ../../../nan/nan.h:56,
                 from ../src/nan/async_callback.cpp:1:
/home/georgehill/.electron-gyp/15.1.2/include/node/v8.h:1684:79: warning: ‘using ResolveCallback = class v8::MaybeLocal<v8::Module> (*)(class v8::Local<v8::Context>, class v8::Local<v8::String>, class v8::Local<v8::Module>)’ is deprecated: Use ResolveModuleCallback [-Wdeprecated-declarations]
 1684 |                                                       ResolveCallback callback);
      |                                                                               ^
/home/georgehill/.electron-gyp/15.1.2/include/node/v8.h:1666:9: note: declared here
 1666 |   using ResolveCallback V8_DEPRECATED("Use ResolveModuleCallback") =
      |         ^~~~~~~~~~~~~~~
⠋ Preparing native dependencies: 0 / 1/home/georgehill/.electron-gyp/15.1.2/include/node/v8.h:8724:51: warning: ‘using HostImportModuleDynamicallyCallback = class v8::MaybeLocal<v8::Promise> (*)(class v8::Local<v8::Context>, class v8::Local<v8::ScriptOrModule>, class v8::Local<v8::String>)’ is deprecated: Use HostImportModuleDynamicallyWithImportAssertionsCallback instead [-Wdeprecated-declarations]
 8724 |       HostImportModuleDynamicallyCallback callback);
      |                                                   ^
/home/georgehill/.electron-gyp/15.1.2/include/node/v8.h:7334:7: note: declared here
 7334 | using HostImportModuleDynamicallyCallback V8_DEPRECATED(
      |       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
⠹ Preparing native dependencies: 0 / 1In file included from ../src/nan/async_callback.cpp:1:
../../../nan/nan.h: In function ‘void Nan::AsyncQueueWorker(Nan::AsyncWorker*)’:
../../../nan/nan.h:2294:62: warning: cast between incompatible function types from ‘void (*)(uv_work_t*)’ {aka ‘void (*)(uv_work_s*)’} to ‘uv_after_work_cb’ {aka ‘void (*)(uv_work_s*, int)’} [-Wcast-function-type]
 2294 |     , reinterpret_cast<uv_after_work_cb>(AsyncExecuteComplete)
      |                                                              ^
⠼ Preparing native dependencies: 0 / 1  CXX(target) Release/obj.target/watcher/src/nan/all_callback.o
⠧ Preparing native dependencies: 0 / 1In file included from /home/georgehill/.electron-gyp/15.1.2/include/node/node.h:63,
                 from ../../../nan/nan.h:56,
                 from ../src/nan/all_callback.cpp:3:
/home/georgehill/.electron-gyp/15.1.2/include/node/v8.h:1684:79: warning: ‘using ResolveCallback = class v8::MaybeLocal<v8::Module> (*)(class v8::Local<v8::Context>, class v8::Local<v8::String>, class v8::Local<v8::Module>)’ is deprecated: Use ResolveModuleCallback [-Wdeprecated-declarations]
 1684 |                                                       ResolveCallback callback);
      |                                                                               ^
/home/georgehill/.electron-gyp/15.1.2/include/node/v8.h:1666:9: note: declared here
 1666 |   using ResolveCallback V8_DEPRECATED("Use ResolveModuleCallback") =
      |         ^~~~~~~~~~~~~~~
/home/georgehill/.electron-gyp/15.1.2/include/node/v8.h:8724:51: warning: ‘using HostImportModuleDynamicallyCallback = class v8::MaybeLocal<v8::Promise> (*)(class v8::Local<v8::Context>, class v8::Local<v8::ScriptOrModule>, class v8::Local<v8::String>)’ is deprecated: Use HostImportModuleDynamicallyWithImportAssertionsCallback instead [-Wdeprecated-declarations]
 8724 |       HostImportModuleDynamicallyCallback callback);
      |                                                   ^
/home/georgehill/.electron-gyp/15.1.2/include/node/v8.h:7334:7: note: declared here
 7334 | using HostImportModuleDynamicallyCallback V8_DEPRECATED(
      |       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
⠏ Preparing native dependencies: 0 / 1In file included from ../src/nan/all_callback.cpp:3:
../../../nan/nan.h: In function ‘void Nan::AsyncQueueWorker(Nan::AsyncWorker*)’:
../../../nan/nan.h:2294:62: warning: cast between incompatible function types from ‘void (*)(uv_work_t*)’ {aka ‘void (*)(uv_work_s*)’} to ‘uv_after_work_cb’ {aka ‘void (*)(uv_work_s*, int)’} [-Wcast-function-type]
 2294 |     , reinterpret_cast<uv_after_work_cb>(AsyncExecuteComplete)
      |                                                              ^
⠼ Preparing native dependencies: 0 / 1  CXX(target) Release/obj.target/watcher/src/nan/functional_callback.o
⠧ Preparing native dependencies: 0 / 1In file included from /home/georgehill/.electron-gyp/15.1.2/include/node/node.h:63,
                 from ../../../nan/nan.h:56,
                 from ../src/nan/functional_callback.cpp:3:
/home/georgehill/.electron-gyp/15.1.2/include/node/v8.h:1684:79: warning: ‘using ResolveCallback = class v8::MaybeLocal<v8::Module> (*)(class v8::Local<v8::Context>, class v8::Local<v8::String>, class v8::Local<v8::Module>)’ is deprecated: Use ResolveModuleCallback [-Wdeprecated-declarations]
 1684 |                                                       ResolveCallback callback);
      |                                                                               ^
/home/georgehill/.electron-gyp/15.1.2/include/node/v8.h:1666:9: note: declared here
 1666 |   using ResolveCallback V8_DEPRECATED("Use ResolveModuleCallback") =
      |         ^~~~~~~~~~~~~~~
⠇ Preparing native dependencies: 0 / 1/home/georgehill/.electron-gyp/15.1.2/include/node/v8.h:8724:51: warning: ‘using HostImportModuleDynamicallyCallback = class v8::MaybeLocal<v8::Promise> (*)(class v8::Local<v8::Context>, class v8::Local<v8::ScriptOrModule>, class v8::Local<v8::String>)’ is deprecated: Use HostImportModuleDynamicallyWithImportAssertionsCallback instead [-Wdeprecated-declarations]
 8724 |       HostImportModuleDynamicallyCallback callback);
      |                                                   ^
/home/georgehill/.electron-gyp/15.1.2/include/node/v8.h:7334:7: note: declared here
 7334 | using HostImportModuleDynamicallyCallback V8_DEPRECATED(
      |       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
⠏ Preparing native dependencies: 0 / 1In file included from ../src/nan/functional_callback.cpp:3:
../../../nan/nan.h: In function ‘void Nan::AsyncQueueWorker(Nan::AsyncWorker*)’:
../../../nan/nan.h:2294:62: warning: cast between incompatible function types from ‘void (*)(uv_work_t*)’ {aka ‘void (*)(uv_work_s*)’} to ‘uv_after_work_cb’ {aka ‘void (*)(uv_work_s*, int)’} [-Wcast-function-type]
 2294 |     , reinterpret_cast<uv_after_work_cb>(AsyncExecuteComplete)
      |                                                              ^
../src/nan/functional_callback.cpp: At global scope:
../src/nan/functional_callback.cpp:17:35: error: ‘Contents’ in ‘class v8::ArrayBuffer’ does not name a type
   17 | using Contents = v8::ArrayBuffer::Contents;
      |                                   ^~~~~~~~
../src/nan/functional_callback.cpp: In function ‘void _fn_callback_helper(const Nan::FunctionCallbackInfo<v8::Value>&)’:
../src/nan/functional_callback.cpp:27:3: error: ‘Contents’ was not declared in this scope
   27 |   Contents cb_contents = cb_array->GetContents();
      |   ^~~~~~~~
../src/nan/functional_callback.cpp:29:43: error: ‘cb_contents’ was not declared in this scope
   29 |   auto *payload = static_cast<intptr_t *>(cb_contents.Data());
      |                                           ^~~~~~~~~~~
../src/nan/functional_callback.cpp:34:10: error: type ‘<type error>’ argument given to ‘delete’, expected pointer
   34 |   delete payload;
      |          ^~~~~~~
⠋ Preparing native dependencies: 0 / 1../src/nan/functional_callback.cpp: In function ‘std::unique_ptr<AsyncCallback> fn_callback(const char*, FnCallback&)’:
../src/nan/functional_callback.cpp:45:95: error: no matching function for call to ‘v8::ArrayBuffer::New(v8::Isolate*, void*, long unsigned int)’
   45 |     ArrayBuffer::New(Isolate::GetCurrent(), static_cast<void *>(payload), sizeof(FnCallback *));
      |                                                                                               ^
In file included from /home/georgehill/.electron-gyp/15.1.2/include/node/node.h:63,
                 from ../../../nan/nan.h:56,
                 from ../src/nan/functional_callback.cpp:3:
/home/georgehill/.electron-gyp/15.1.2/include/node/v8.h:5446:29: note: candidate: ‘static v8::Local<v8::ArrayBuffer> v8::ArrayBuffer::New(v8::Isolate*, size_t)’
 5446 |   static Local<ArrayBuffer> New(Isolate* isolate, size_t byte_length);
      |                             ^~~
/home/georgehill/.electron-gyp/15.1.2/include/node/v8.h:5446:29: note:   candidate expects 2 arguments, 3 provided
/home/georgehill/.electron-gyp/15.1.2/include/node/v8.h:5460:29: note: candidate: ‘static v8::Local<v8::ArrayBuffer> v8::ArrayBuffer::New(v8::Isolate*, std::shared_ptr<v8::BackingStore>)’
 5460 |   static Local<ArrayBuffer> New(Isolate* isolate,
      |                             ^~~
/home/georgehill/.electron-gyp/15.1.2/include/node/v8.h:5460:29: note:   candidate expects 2 arguments, 3 provided
make: *** [watcher.target.mk:153: Release/obj.target/watcher/src/nan/functional_callback.o] Error 1
make: Leaving directory '/home/georgehill/Desktop/GH/FF/test-atom-watcher/my-new-app/node_modules/@atom/watcher/build'
✖ Preparing native dependencies: 0 / 1

An unhandled error has occurred inside Forge:
node-gyp failed to rebuild '/home/georgehill/Desktop/GH/FF/test-atom-watcher/my-new-app/node_modules/@atom/watcher'.
For more information, rerun with the DEBUG environment variable set to "electron-rebuild".

Error: `make` failed with exit code: 2


Error: node-gyp failed to rebuild '/home/georgehill/Desktop/GH/FF/test-atom-watcher/my-new-app/node_modules/@atom/watcher'.
For more information, rerun with the DEBUG environment variable set to "electron-rebuild".

Error: `make` failed with exit code: 2


    at NodeGyp.rebuildModule (/home/georgehill/Desktop/GH/FF/test-atom-watcher/my-new-app/node_modules/electron-rebuild/src/module-type/node-gyp.ts:120:13)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at ModuleRebuilder.rebuildNodeGypModule (/home/georgehill/Desktop/GH/FF/test-atom-watcher/my-new-app/node_modules/electron-rebuild/src/module-rebuilder.ts:93:5)
    at Rebuilder.rebuildModuleAt (/home/georgehill/Desktop/GH/FF/test-atom-watcher/my-new-app/node_modules/electron-rebuild/src/rebuild.ts:299:5)
    at Rebuilder.rebuild (/home/georgehill/Desktop/GH/FF/test-atom-watcher/my-new-app/node_modules/electron-rebuild/src/rebuild.ts:200:9)
    at /home/georgehill/Desktop/GH/FF/test-atom-watcher/my-new-app/node_modules/@electron-forge/core/src/util/rebuild.ts:32:5
georgehill@ubuntu:~/Desktop/GH/FF/test-atom-watcher/my-new-app$ 

Node version: 16.11.0
NPM version: 8.0.0
Ubuntu 20.04.3.

On a different system, I have also tried Electron's native module installation instructions as spelled out here:

https://www.electronjs.org/docs/tutorial/using-native-node-modules

But none of them worked.

Is there any way to use atom watcher with Electron?

Thank you.

@LoganDark
Copy link
Author

@george-thomas-hill I am also using Electron Forge. Your issue is the same as mine. This module does not support Electron versions higher than 12

@taratatach
Copy link

@smashwilson @lkashef Hi guys. This issue is starting to be a big problem as Electron versions keep increasing without any means for us to upgrade.
Do you think you could help with the C++ upgrade? I've tried it myself but I'm no C++ dev and I'm not very familiar with atom/watcher's code base so I was unsuccessful :/.

I'm happy to help in any way I can though!

@loqs
Copy link

loqs commented Mar 13, 2022

@taratatach did you try something like:

diff --git a/src/nan/functional_callback.cpp b/src/nan/functional_callback.cpp
index 37aa897..5732244 100644
--- a/src/nan/functional_callback.cpp
+++ b/src/nan/functional_callback.cpp
@@ -24,9 +24,12 @@ void _noop_callback_helper(const FunctionCallbackInfo<Value> & /*info*/)
 void _fn_callback_helper(const FunctionCallbackInfo<Value> &info)
 {
   Local<ArrayBuffer> cb_array = info.Data().As<ArrayBuffer>();
-  Contents cb_contents = cb_array->GetContents();
+#if (V8_MAJOR_VERSION >= 8)
+  auto *payload = static_cast<intptr_t *>(cb_array->GetBackingStore()->Data());
+#else
+  auto *payload = static_cast<intptr_t *>(cb_array->GetContents().Data());
+#endif
 
-  auto *payload = static_cast<intptr_t *>(cb_contents.Data());
   assert(cb_contents.ByteLength() == sizeof(FnCallback *));
 
   auto *fn = reinterpret_cast<FnCallback *>(*payload);
diff --git a/src/worker/linux/cookie_jar.h b/src/worker/linux/cookie_jar.h
index 05d33a3..8c36879 100644
--- a/src/worker/linux/cookie_jar.h
+++ b/src/worker/linux/cookie_jar.h
@@ -17,7 +17,7 @@
 class Cookie
 {
 public:
-  Cookie(ChannelID channel_id, std::string &&from_path, EntryKind kind);
+  Cookie(ChannelID channel_id, std::string &&from_path, EntryKind kind) noexcept;
   Cookie(Cookie &&other) noexcept;
   ~Cookie() = default;
 

@taratatach
Copy link

@loqs your changes are not enough for the software to compile. There still are references to cb_contents and the use of old ArrayBuffer::New() signature calls.

I did manage to get the software to compile but not for the tests to fully pass (and I get the same crashes when trying to use the resulting binary in my project).
You can see where I'm at here : #243

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants