open-wa/wa-automate-nodejs

altSessionJsonPath execption: path is not a string #1266

gnadelwartz posted onGitHub

Describe the bug After Update to 3.1.15 I get an execption when WA-Automate loads the session on startup 1.3.13 is working.

create() code This is the code you use to create the client. e.g

create(...)

Expected behavior no execprion ;-)

DEBUG INFO This is the info printed to the console when you start your app. It should look like this

ā”‚     WA_VERSION      ā”‚                                                                  '2.2100.6'                                                                  ā”‚
ā”‚       PAGE_UA       ā”‚ 'WhatsApp/2.2037.6 Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.83 Safari/537.36' ā”‚
ā”‚ WA_AUTOMATE_VERSION ā”‚                                                                   '3.1.15'                                                                   ā”‚
ā”‚   BROWSER_VERSION   ā”‚                                                         'HeadlessChrome/88.0.4298.0'                                                         ā”‚
ā”‚         OS          ā”‚                                                                 'Linux 5.3'                                                                  ā”‚
ā”‚      START_TS       ā”‚                                                                1611333653610                                                                 ā”‚

Screenshots If applicable, add screenshots to help explain your problem. Use headless: false to get screenshots

Additional context Add any other context about the problem here.

seems to boil down to initalisation of altSessionJsonPath in node-modules/@open-wa/wa-automate/dist/controllers/initializer.js .

My temporary fix ist to set altSessionJsonPath to an empty string in line 313

    altSessionJsonPath = "" //((config === null || config === void 0 ? void 0 : config.sessionDataPath) && (config === null || config === void 0 ? void 0 : config.sessionDataPath.includes('.data.json'))) ? path.join(path.resolve(require.main.path, (config === null || config === void 0 ? void 0 : config.sessionDataPath) || '')) : path.join(path.resolve(require.main.path, (config === null || config === void 0 ? void 0 : config.sessionDataPath) || ''), (sessionId || 'session') + ".data.json");
    sessionjsonpath = fs.existsSync(altSessionJsonPath) ? altSessionJsonPath : stdSessionJsonPath;

After this I can at least start my WA BOT

Ah, have to mention that everthing is in and run in one flat dir, no src subdir etc., only node-modules

-r-xr-xr-x        2068 22. Jan 15:28 dealwaecho.rc
-rw-r--r--         6858 22. Jan 15:30 dealwaecho.ts
-rw-r--r--            476  1. Feb 2020  .eslintrc.json
drwxr-xr-x    20480 22. Jan 17:32 node_modules
-rw-r--r--     210837 22. Jan 17:32 package-lock.json
-rw-r--r--            544 22. Jan 17:40 session.data.json

@gnadelwartz great thanks for the context and proposed fix . Will implement by tonight. Thanks a ton.

posted by smashah about 4 years ago

@gnadelwartz terima kasih banyak atas konteks dan usulan perbaikannya. Akan dilaksanakan malam ini. Terima kasih banyak.

Has this case been fixed?

posted by bagusdwip about 4 years ago

@github-actions run

<details> <summary>āš” Release! āš”</summary>

(async () => {
function exec(cmd) {
  console.log(execSync(cmd).toString());
}

// Config
const gitUserEmail = "github-actions[bot]@users.noreply.github.com";
const gitUserName = "github-actions[bot]";

exec(`echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" > .npmrc`);
exec(`git config --global user.email "${gitUserEmail}"`);
exec(`git config --global user.name "${gitUserName}"`);
exec(`npm i -D`);
exec(`npm run release-ci`);

//comment on the issue
var result = execSync(`npx auto-changelog -o ./tempchangelog.txt --commit-limit false --template ./compact-keepachangelog.hbs --stdout`).toString();

    await postComment(result);

//create changelog image
exec(`npm run release-image`);
exec(`git commit -a -m 'updated release-image'`);
exec(`git push --force`);
  })();

</details>

posted by smashah about 4 years ago

Changelog

šŸš€ Release 3.1.16 (2021-01-23)

  • build(deps-dev): bump @types/express from 4.17.9 to 4.17.11 #1260
  • build(deps-dev): bump @types/node from 14.14.20 to 14.14.22 #1261
  • build(deps): bump ts-json-schema-generator from 0.82.0 to 0.83.2 #1259
  • Release 3.1.16 f79a200
  • added support for node<14 support for main module relative session data and posssible fix for #1266 6a8d79c
posted by smashah about 4 years ago

@gnadelwartz @bagusdwip I wasn't able to recreate the issue entirely but hopefully the changed in 3.1.16 have fixed the problems. Please try it out and let me know/ provide some more context thanks

posted by smashah about 4 years ago

Can confirm it's working for me, thanks!

posted by gnadelwartz about 4 years ago

great!

posted by smashah about 4 years ago

Version 3.10.5 re-introduces this "path is not a sting exception" due to refactoring detection ... pls reopen

going back to 3.10.4 fix the problem ...

posted by gnadelwartz almost 4 years ago

@gnadelwartz

Can you confirm your node version please

https://github.com/open-wa/wa-automate-nodejs/issues/1538#issuecomment-811542308

posted by smashah almost 4 years ago

I'm using the officially supported node Version of OpenSuse, unforunately this is Node 10. I understand that some modern projects use newer versions, but there is no newer version avalible for OpenSuse.

There seems to be an experimental Node 15 package for OpenSuse and Developer Rolling Release Suse Tumbleweed: https://software.opensuse.org/package/nodejs15

will this be suffcient from your point of view?

posted by gnadelwartz almost 4 years ago

@gnadelwartz no idea as I've never used opensuse. From that linked issue, you can see that I implemented a fix to this error showing up. In the next release, this problem will be resolved. So remain on 3.10.4 for now and then install the 3.10.6 when it is available.

posted by smashah almost 4 years ago

thank you, I'll try next version.

posted by gnadelwartz almost 4 years ago
posted by smashah almost 4 years ago

3.10.7 is working again, Thanks!

posted by gnadelwartz almost 4 years ago

@smashah I had to go back to 3.10.4 as it's starting but stop receiving messages with 3.10.7. I'll debug after eastern to see where its failing ...

posted by gnadelwartz almost 4 years ago

Fund this Issue

$0.00
Funded

Pull requests