Adobe-CEP / CEP-Resources

Tools and documentation for building Creative Cloud app extensions with CEP
https://www.adobe.io/apis/creativecloud/cep.html
1.62k stars 828 forks source link

CEP10: cep_node.global.require is not a function #335

Open alien1976 opened 3 years ago

alien1976 commented 3 years ago

Hello,

I am hitting the following error inside the debug console with the latest CEP 10.

process_main:1 Uncaught TypeError: cep_node.global.require is not a function
    at process_main:1

This is happening when I refresh the page. On initial load cep_node.global.require is defined and there are no problems. When I refresh the page for the first time then cep_node.global.require is undefined and when I refresh the page again the error above is logged to the console.

The extension is integrated inside Adobe Animate.

Anyway, I followed the steps from the issues section of CEP 10 here, updated node js to 12.3.1 which is the version for CEP10, and performed npm update, npm install to my project with the new node version. However, these steps do not fix the problem above.

Am I missing something or there is a problem with the CEP that is not solvable by me?

sujaisivanandan commented 3 years ago

@alien1976

can you take a look at this thread - https://github.com/Adobe-CEP/CEP-Resources/issues/328 I think you have some of the node modules that uses duplex. Adding the script mentioned in the thread should resolve this issue. Please let me know if this helped?

alien1976 commented 3 years ago

@sujaisivanandan Thanks for the fast response! I've tried to add the mentioned script to the extension but without any result. It may be useful information to know that I am just using fs, path, child_process modules from the cep_node and also accessing the process.env

sujaisivanandan commented 3 years ago

@alien1976 would it be possible for you to send a sample extension which demonstrates the problem? I'm not able to see this problem on any of my extensions.

alien1976 commented 3 years ago

@sujaisivanandan Right now I am working with Adobe Animate so the easiest way to produce the problem is to:

and

./index.html to ./index.html --enable-nodejs ``` * Open Animate * Create SamplePlugin document * Open publish settings * Open inspector with the port provided inside the `.debug` file * Refresh the page 3 times or more and the error will be logged to the console then. If the `
rahul-dutt-sharma commented 3 years ago

How did u install the file? This seems as if the old zxp replaced what ever you did. ExMan.db file can be cleaned to remove the plugins cached. but that will remove all

alien1976 commented 3 years ago

@rahul-dutt-sharma I've installed the sample extension's zxp via the latest Anastasiy manager. I've also tried to clean manually all the custom extensions from the C:\Program Files (x86)\Common Files\Adobe\CEP\extensions and then install the sample plugin without any result. The error is still there.

rahul-dutt-sharma commented 3 years ago

Then thats the issue, u cant edit the signed plugin once installed I u wish to edit, u need to follow the debug section of the guide in this repo. Remove the one u installed. Then rename the .zxp to .zip. Extract place in the extensions folder restart the CC tool Test your changes

rahul-dutt-sharma commented 3 years ago

You might want to check in the guide... the folder C:\Program Files (x86)\Common Files\Adobe\CEP\extensions is not the proper place to place user level extensions. Its inside the /Users//AppData or similar

alien1976 commented 3 years ago

@rahul-dutt-sharma
I don't know why the installation folder may cause the problem with cep_node mentioned above but ok. Also using the Anastasiy manager or ExManCmd for installing the zxp file will always copy the files to the System extension folder (or C:\Program Files (x86)\Common Files\Adobe\CEP\extensions). Even I install some extensions from the Creative Cloud Desktop they are installed to C:\Program Files (x86)\Common Files\Adobe\CEP\extensions. How I can install an extension inside the Per-user extension folder with a tool like you told me? For now, I am able to do that manually. There are no additional steps in your documentation about this case or I did not find any. Can you link me the guide where it is described how the extensions are installed to the Per user extension folder?

However, I've tried to place the files from the sample plugin's zxp inside Per-user extension folder which is located inside C:\Users\<USERNAME>\AppData\Roaming\Adobe\CEP/extensions (sometimes this folder is deleted when I install some extension through the managers mentioned above so I needed to create this folder manually). The sample plugin works normally but the problem with the cep_node is still there. I am attaching a zip with the sample plugin and modified files so you can unzip it inside C:\Users\<USERNAME>\AppData\Roaming\Adobe\CEP/extensions and check the problem.

Thanks in advance :)

SamplePlugin.zip

PS. Also I am using the latest Adobe Animate 2021 version 21.0.1 but the problem is there in 21.0.0 as well.

rahul-dutt-sharma commented 3 years ago

ExManCmd can be used to remove. If the system level folder is fine for you then its ok. https://github.com/Adobe-CEP/CEP-Resources/blob/master/CEP_10.x/Documentation/CEP%2010.0%20HTML%20Extension%20Cookbook.md#debugging-unsigned-extensions is where the debugging steps are. You need to remove the extension installed via ExMax so that they are not reverted Then u need to enable unsigned extensions, make changes in the code and then you should be good to go

rahul-dutt-sharma commented 3 years ago

Let me know if u need help with Exman

chris-at-cimpress commented 3 years ago

Why is CEP 10 trying to access cep_node.global.require? When connected with the Chrome devtool, I see that cep_node.global.require does not exist. There is a cep_node.require, but that's not what the error is about. Even with a minimal setup, just the act of reloading the extension (such as with Live Reloading) will cause the extension to crash repeatedly in an endless loop with this "cep_node.global.require is not a function" error message and an "--OOPS! Render process terminated---" error message in the logs. The crash report shows a SIGSEGV error in CEPHtmlEngine Helper.

sujaisivanandan commented 3 years ago

We had some developers report this and few troubleshooting steps are mentioned at https://github.com/Adobe-CEP/CEP-Resources/blob/master/CEP_10.x/Documentation/Issues.md. Can you check if this helps

chris-at-cimpress commented 3 years ago

Thanks, I have already reported this crash elsewhere. I've already tried updating my modules and checked for the presence of CEPEngine_extensions.js. My question here is for my understanding: what is trying to access cep_node.global.require?

sujaisivanandan commented 3 years ago

Hi @chris-at-cimpress

we use this in CEP runtime in an internal script that provides the node functionality. When there is a crash in node and the CEF restarts, this error shows up. So, when this error pops up, its generally some issue with the node functionality.

Note: in CEP 10 we use NodeJs v12.3.1

chris-at-cimpress commented 3 years ago

Thanks. Every case seems to be different even if they result in this error message. In my case, it seems to be related to changes in the way CEP handles redirects.

alien1976 commented 3 years ago

For my end the fix was the same as in #343 - simply add this flag to the manifest file.

<Parameter>--mixed-context</Parameter>