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

"method" can be undefined in "callConductor" #30

Open
mjbrisebois opened this issue Sep 30, 2020 · 0 comments
Open

"method" can be undefined in "callConductor" #30

mjbrisebois opened this issue Sep 30, 2020 · 0 comments

Comments

@mjbrisebois
Copy link
Contributor

If any code fails before method is assigned the method would remain undefined. This code is quite messy and should be made less complicated. Once issue #14 is complete, we can depend on the client being resilient to past interruptions. Then this code should be restructured to also be more resilient.

PR #28 is a temporary fix that raises the first try/catch error.

https://github.com/Holo-Host/holo-envoy/blob/develop/src/index.ts#L690-L716

	let method;
	try {
	    if ( typeof client === "string" )
		client			= this.hcc_clients[ client ];

	    let ready_state		= client.socket.readyState;
	    if ( ready_state !== 1 ) {
		log.silly("Waiting for 'CONNECTED' state because current ready state is %s (%s)", ready_state, READY_STATES[ready_state] );
		await client.opened();
	    }

	    // Assume the method is "call" unless `call_spec` is a string.
	    method			= "call";
	    if ( typeof call_spec === "string" ) {
		log.debug("Admin call spec details: %s( %s )", () => [
		    call_spec, Object.entries(args).map(([k,v]) => `${k} : ${typeof v}`).join(", ") ]);
		method			= call_spec;
	    }
	    else {
		log.debug("Call spec details: %s::%s->%s( %s )", () => [
		    call_spec.instance_id, call_spec.zome, call_spec.function, Object.entries(call_spec.args).map(([k,v]) => `${k} : ${typeof v}`).join(", ") ]);
		args			= call_spec;
	    }
	} catch ( err ) {
	    console.log("callConductor preamble threw", err );
      throw new HoloError("callConductor preamble threw error: %s", String(err));
	}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant