wasm-tools icon indicating copy to clipboard operation
wasm-tools copied to clipboard

wit-component: Reactors should call `_initialize`

Open ospencer opened this issue 1 year ago • 2 comments

When using wasm-tools component new with --adapt pointed to a reactor adapter, it'd be great if _initialize was called in the resulting component, maybe via (start).

Currently, there's no way to access and call _initialize unless you specify it in a wit file, but that feels odd.

ospencer avatar Mar 20 '24 20:03 ospencer

One of the main difficulties of _initialize-vs-(start) is that _initialize is separate from (start) to ensure that it's only invoked once all imports to the module are "ready". For components, for example, imports aren't ready when (start) is invoked meaning that we wouldn't be able to put _initialize there. That being said we could perhaps synthesize a second module which imports _initialize and is instantiated after all imports are "ready", and I think that'd be a reasonable change to make.

alexcrichton avatar Mar 25 '24 15:03 alexcrichton

My apologies, I thought there was a component-level (start) as opposed to core wasm's, but I might have been mistaken. What I was hoping for is exactly what you mentioned.

ospencer avatar Mar 27 '24 19:03 ospencer