Skip to content

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

Open

Description

@efekurnaz

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

Activity

  1. NewEraCracker commented on Oct 25, 2023

    @NewEraCracker

    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.

  2. NewEraCracker commented on Oct 25, 2023

    @NewEraCracker

    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");
  3. self-assigned this
    on Oct 25, 2023
  4. moved this from Icebox to Current/Backlog in LoopBack Common Project Boardon Oct 25, 2023
  5. added a commit that references this issue on Oct 25, 2023
  6. NewEraCracker commented on Mar 15, 2024

    @NewEraCracker

    @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

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions