CEP-Resources icon indicating copy to clipboard operation
CEP-Resources copied to clipboard

CEP10: cep_node.global.require is not a function

Open alien1976 opened this issue 4 years ago • 17 comments

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?

alien1976 avatar Dec 14 '20 09:12 alien1976

@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?

sujaisivanandan avatar Dec 14 '20 09:12 sujaisivanandan

@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

alien1976 avatar Dec 14 '20 12:12 alien1976

@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.

sujaisivanandan avatar Dec 15 '20 05:12 sujaisivanandan

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

  • Download the SamplePlugin from https://console.adobe.io/downloads
  • Install the SamplePlugin - the zxp is inside the archive
  • Add debugging port with a .debug file to the extension folder where installed
  • Modify the manifest file
<ExtensionManifest Version="4.0" to <ExtensionManifest Version="7.0"

and

<MainPath>./index.html</MainPath> to 
<MainPath>./index.html</MainPath>
<CEFCommandLine>
	<Parameter>--enable-nodejs</Parameter>
</CEFCommandLine>
  • 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 <ExtensionManifest Version="4.0" is not changed to <ExtensionManifest Version="7.0" the problem is not reproduced as well as cep_node is not defined.

I am not 100% sure but the problem may be also caused by Animate. If so I will send them bug also.

alien1976 avatar Dec 15 '20 10:12 alien1976

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

rahul-dutt-sharma avatar Dec 22 '20 11:12 rahul-dutt-sharma

@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.

alien1976 avatar Dec 22 '20 11:12 alien1976

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 avatar Dec 22 '20 11:12 rahul-dutt-sharma

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

rahul-dutt-sharma avatar Dec 22 '20 11:12 rahul-dutt-sharma

@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.

alien1976 avatar Dec 22 '20 13:12 alien1976

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 avatar Dec 22 '20 13:12 rahul-dutt-sharma

Let me know if u need help with Exman

rahul-dutt-sharma avatar Dec 22 '20 13:12 rahul-dutt-sharma

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.

chris-at-cimpress avatar Jan 04 '21 22:01 chris-at-cimpress

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

sujaisivanandan avatar Jan 05 '21 08:01 sujaisivanandan

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?

chris-at-cimpress avatar Jan 05 '21 17:01 chris-at-cimpress

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

sujaisivanandan avatar Jan 06 '21 05:01 sujaisivanandan

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.

chris-at-cimpress avatar Jan 06 '21 13:01 chris-at-cimpress

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

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

alien1976 avatar Feb 08 '21 14:02 alien1976