sverweij/state-machine-cat

smcat fails with: Invalid asm.js: Function definition doesn't match use

bsutton opened this issue · 6 comments

I have an smc file (at end of issue) which renders correctly using https://state-machine-cat.js.org

When I try to visualise this file from the cli I'm getting an error:

smcat select_registration.gv 
(node:1596406) V8: /usr/lib/node_modules/state-machine-cat/node_modules/viz.js/viz.js:33 Invalid asm.js: Function definition doesn't match use
smcat -V
7.0.13

I'm using the version installed via npm and I'm running on ubuntu 20.10.

During the install I saw one warning:

sudo npm install --global state-machine-cat
npm WARN deprecated viz.js@1.8.2: no longer supported
/usr/bin/smcat -> /usr/lib/node_modules/state-machine-cat/bin/smcat
/usr/bin/sm_cat -> /usr/lib/node_modules/state-machine-cat/bin/smcat
/usr/bin/state-machine-cat -> /usr/lib/node_modules/state-machine-cat/bin/smcat
/usr/bin/sm-cat -> /usr/lib/node_modules/state-machine-cat/bin/smcat

> fast-xml-parser@3.17.4 postinstall /usr/lib/node_modules/state-machine-cat/node_modules/fast-xml-parser
> node tasks/postinstall.js || exit 0

Love fast-xml-parser? Check https://amitkumargupta.work for more projects and contribution.

+ state-machine-cat@7.0.13
added 36 packages from 56 contributors in 2.169s
AppLaunched {
	AppLaunched => RegistrationRequired : OnForceRegistration;
	AppLaunched => RegistrationRequired : OnMissingApiKey;
	AppLaunched => Registered : OnHasApiKey;
},
Registered {
	Registered => RegistrationRequired : OnForceRegistration;
},
RegistrationRequired {
	RegistrationTypeAcquired {
		NewOrganisation,
		RecoverAccount,
		AcceptInvitation;
NewOrganisation.initial => NewOrganisation;
	};
RegistrationTypeAcquired.initial => RegistrationTypeAcquired;
	RegistrationRequired => AcceptInvitation : OnRegistrationType;
	RegistrationRequired => NewOrganisation : OnRegistrationType;
	RegistrationRequired => RecoverAccount : OnRegistrationType;
};
initial => AppLaunched : AppLaunched;

hi @bsutton - thanks for taking the time to raise this issue. It seems you've bumped into #82 (see also the FAQ).

You'll probably find the svg was generated correctly (I've tried under node 15 with your input, which is valid smcat) in spite of the warning message.

If you don't want to see the warning message you can always use the native graphviz dot, which typically ships with your linux distro e.g. smcat -T dot your-machine.smcat | dot -T svg > your-machine.svg.

@bsutton that's an option idd. Or keeping svg the default, but first trying it with the native dot (in a child process). And only use viz.js as a fallback. That way it's easier to provide the scary message with context + remediation. Sounds like a nice task for over the weekend.

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.

hey @bsutton in state-machine-cat@7.1.0 the command line version by default will try with the native dot version when it is available. An smcat command will then do quietly do it's work.

When dot is not available, state-machine-cat willl use viz.js as a fallback accompanied with some context on stderr:

warning: GraphViz 'dot' executable not found. Falling back to svg.js.

On node >=12 this fallback will trigger a warning from the node runtime:
Invalid asm.js: Function definition doesn't match use.
It's harmless and the svg will generate just fine. However, if you want to
avoid the warning install GraphViz and make sure it's available in your path.