Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

/src/security/index not found on Vercel serverlesss function. #636

Open
efekurnaz opened this issue Sep 30, 2023 · 4 comments · May be fixed by #647
Open

/src/security/index not found on Vercel serverlesss function. #636

efekurnaz opened this issue Sep 30, 2023 · 4 comments · May be fixed by #647
Assignees

Comments

@efekurnaz
Copy link

efekurnaz commented Sep 30, 2023

I'm using strong-soap basically with require const soap = require('strong-soap').soap;

App works perfectly fine on local ngrok but it crashes on Vercel. Is there anything we can do to fix this?

The error in the Vercel log:

Cannot find module './src/security/index'
Require stack:
- /var/task/node_modules/strong-soap/index.js
- /var/task/aramex.js
- /var/task/handlers.js
- /var/task/routes.js
- /var/task/index.js
Did you forget to add it to "dependencies" in `package.json`?
Error: Runtime exited with error: exit status 1
Runtime.ExitError
@efekurnaz efekurnaz reopened this Oct 1, 2023
@NewEraCracker
Copy link

I'm trying to compile strong-soap as a binary in a custom JavaScript solution, and stumbled upon the same error message.

Apply this patch, but you may run into other errors relating to dynamic imports.

diff --git a/node_modules/strong-soap/index.js b/node_modules/strong-soap/index.js
index 701ff00..e44a612 100644
--- a/node_modules/strong-soap/index.js
+++ b/node_modules/strong-soap/index.js
@@ -5,20 +5,17 @@
 
 'use strict';
 
-var base = './lib/';
+var base = './src/';
 var nodeVersion = process.versions.node;
 var major = Number(nodeVersion.split('.')[0]);
-if (major >= 4) {
-  base = './src/';
-}
 
-var securityModules = require(base + 'security/index');
+var securityModules = require('./src/security/index');
 
 module.exports = {
-  'soap': require(base + 'soap'),
-  'http': require(base + 'http'),
-  'QName': require(base + 'parser/qname'),
-  'WSDL': require(base + 'parser/wsdl'),
+  'soap': require('./src/soap'),
+  'http': require('./src/http'),
+  'QName': require('./src/parser/qname'),
+  'WSDL': require('./src/parser/wsdl'),
 };
 
 for (var i in securityModules) {

Also from README « Node.js version 10, 12, and 14 are officially supported. We dropped version 8 support in 3.0.0. », then I wonder why there is a piece of code to support node.js 4.

My two cents, and hoping it helps.

@NewEraCracker
Copy link

NewEraCracker commented Oct 25, 2023

And for the dynamic imports, as a workaround, I am presently using a different entry point to my custom www.js application:

/* eslint-disable */

// The packaging tool is unable to recognize dynamic imports,
// however we can workaround this by doing the imports ourselves
require("strong-globalize/cldr/cldr_32.0.1.json");

// find ./node_modules/strong-soap/intl/ -type f | sed 's/.\/node_modules\///g' | sort | sed 's/.*/require\("&"\);/g'
require("strong-soap/intl/cs/messages.json");
require("strong-soap/intl/de/messages.json");
require("strong-soap/intl/en/messages.json");
require("strong-soap/intl/es/messages.json");
require("strong-soap/intl/fr/messages.json");
require("strong-soap/intl/it/messages.json");
require("strong-soap/intl/ja/messages.json");
require("strong-soap/intl/ko/messages.json");
require("strong-soap/intl/nl/messages.json");
require("strong-soap/intl/pl/messages.json");
require("strong-soap/intl/pt/messages.json");
require("strong-soap/intl/ru/messages.json");
require("strong-soap/intl/tr/messages.json");
require("strong-soap/intl/zh-Hans/messages.json");
require("strong-soap/intl/zh-Hant/messages.json");
require("strong-soap/intl/zz/messages_inverted.json");
require("strong-soap/intl/zz/messages.json");

require("./www.js");

@achrinza achrinza self-assigned this Oct 25, 2023
achrinza added a commit that referenced this issue Oct 25, 2023
fixes: #636
Signed-off-by: Rifa Achrinza <[email protected]>
@achrinza achrinza linked a pull request Oct 25, 2023 that will close this issue
1 task
@noddy-cred
Copy link

noddy-cred commented Mar 15, 2024

And for the dynamic imports, as a workaround, I am presently using a different entry point to my custom www.js application:

/* eslint-disable */

// The packaging tool is unable to recognize dynamic imports,
// however we can workaround this by doing the imports ourselves
require("strong-globalize/cldr/cldr_32.0.1.json");

// find ./node_modules/strong-soap/intl/ -type f | sed 's/.\/node_modules\///g' | sort | sed 's/.*/require\("&"\);/g'
require("strong-soap/intl/cs/messages.json");
require("strong-soap/intl/de/messages.json");
require("strong-soap/intl/en/messages.json");
require("strong-soap/intl/es/messages.json");
require("strong-soap/intl/fr/messages.json");
require("strong-soap/intl/it/messages.json");
require("strong-soap/intl/ja/messages.json");
require("strong-soap/intl/ko/messages.json");
require("strong-soap/intl/nl/messages.json");
require("strong-soap/intl/pl/messages.json");
require("strong-soap/intl/pt/messages.json");
require("strong-soap/intl/ru/messages.json");
require("strong-soap/intl/tr/messages.json");
require("strong-soap/intl/zh-Hans/messages.json");
require("strong-soap/intl/zh-Hant/messages.json");
require("strong-soap/intl/zz/messages_inverted.json");
require("strong-soap/intl/zz/messages.json");

require("./www.js");

Did you have to do anything special to get cldr to work? I'm getting similar issues using Firebase Functions. I've changed my entry point to a new file that includes the above, but get the following:

Error: ENOENT: no such file or directory, lstat '/src/dist/apps/cldr'
    at Object.realpathSync (node:fs:2655:7)
    at alreadyScanned (/node_modules/strong-globalize/src/helper.ts:221:56)
    at enumerateFilesSyncPriv (/node_modules/strong-globalize/src/helper.ts:243:7)
    at enumerateFilesSync (/node_modules/strong-globalize/src/helper.ts:209:10)
    at getSupportedLanguages (/node_modules/strong-globalize/src/helper.ts:719:3)
    at Object.isSupportedLanguage (/node_modules/strong-globalize/src/helper.ts:708:37)
    at osLanguage (/node_modules/strong-globalize/src/globalize.ts:50:14)
    at node_modules/strong-globalize/lib/globalize.js (/node_modules/strong-globalize/src/globalize.ts:42:17)
    at __require (/src/dist/apps/cred-cloud-api/main.js:13:51)
    at node_modules/strong-globalize/lib/strong-globalize.js (/node_modules/strong-globalize/src/strong-globalize.ts:7:1) {
   errno: -2,
  syscall: 'lstat',
   code: 'ENOENT',
   path: '/src/dist/apps/cldr'
 }

Did you have to copy any additional packages into your bundle?

@NewEraCracker
Copy link

@noddy-cred I think you may need to declare cldr explicitly (and other dependencies of strong-soap?) as a dependency of your firebase project to make the SDK deploy that module.

PS: I've added after www.js require some stuff like the following:

// ... the forced requires
// entry point
require("./www.js");
// code to dump require cache and find something interesting
setTimeout(() => {
  let dump = Object.keys(require.cache);
  dump = JSON.stringify(dump, null, 2);
  require('fs').writeFileSync('dump.txt', dump, 'utf-8');
  console.log('dumped requires');
}, 60000).unref();

To dump all imported modules after I call the APIs on www.js to see what gets required.

IMO strong-soap needs to be redesigned for the serverless world. I've found another alternative/solution for my issue, but am bound by NDA.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Current/Backlog
Development

Successfully merging a pull request may close this issue.

4 participants