Skip to content

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

@mjbrisebois

Description

@mjbrisebois

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));
	}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions