You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
import{HandleRequest,HttpRequest,HttpResponse,Router,Config// THIS DOES NOT WORK BUT DOES WHEN COMMENTED OUT }from"@fermyon/spin-sdk";import{withCorrelationId}from"./middlewares";constencoder=newTextEncoder();constdecoder=newTextDecoder("utf-8");constrouter=Router();// let libsql_url = Config.get("libsql_url"); // THIS IS WHERE I WANTED TO USE THE CONFIG IMPORT// ...// rest of the code goes here// ....
Unexpected Behaviour:
picasso@picasso:~/Desktop/src/projects/wasm/spin/spin-ts-api$ spin build
Building component spin-ts-api with `npm run build`> spin-ts-api@1.0.0 build
> npx webpack --mode=production && mkdir -p target && spin js2wasm -o target/spin-ts-api.wasm dist/spin.js
asset spin.js 13.9 KiB [compared for emit] (name: main)
orphan modules 6.09 KiB [orphan] 12 modules
runtime modules 937 bytes 4 modules
cacheable modules 10.8 KiB
./src/index.ts + 6 modules 10.2 KiB [built] [code generated]
./node_modules/typedarray-to-buffer/index.js 646 bytes [built] [code generated]
webpack 5.90.0 compiled successfully in 1791 ms
Starting to build Spin compatible module
Preinitiating using Wizer
Error: the `wizer.initialize`functiontrapped
Caused by:
0: error while executing at wasm backtrace:
0: 0x6c4c0 - <unknown>!spin_sdk::wit::fermyon::spin::config::get_config::h4d5943445acc57cc
1: 0x2905e - <unknown>!spin_js_engine::spin_get_config::h125755b80cf5df1a
2: 0x18588 - <unknown>!quickjs_wasm_rs::js_binding::context::build_trampoline::trampoline::hdd2b62f9d273076d
3: 0x93696 - <unknown>!js_c_function_data_call
4: 0x94d53 - <unknown>!JS_CallInternal
5: 0x96b35 - <unknown>!JS_CallInternal
6: 0x96971 - <unknown>!JS_CallInternal
7: 0x96971 - <unknown>!JS_CallInternal
8: 0xc4301 - <unknown>!JS_EvalFunctionInternal
9: 0xa8f36 - <unknown>!__JS_EvalInternal
10: 0xc5209 - <unknown>!JS_Eval
11: 0x78604 - <unknown>!quickjs_wasm_rs::js_binding::context::Context::eval_global::h5e906feb1352150b
12: 0x364e5 - <unknown>!wizer.initialize
note: using the `WASMTIME_BACKTRACE_DETAILS=1` environment variable may show more debugging information
1: Error: attempted to call an unknown imported function: 'fermyon:spin/config''get-config'
You cannot call arbitrary imported functions during Wizer initialization.
Error: Couldn't create wasm from inputError: Build command for component spin-ts-api failed with status Exited(1)
The applications builds when the import is removed
picasso@picasso:~/Desktop/src/projects/wasm/spin/spin-ts-api$ spin build
Building component spin-ts-api with `npm run build`> spin-ts-api@1.0.0 build
> npx webpack --mode=production && mkdir -p target && spin js2wasm -o target/spin-ts-api.wasm dist/spin.js
asset spin.js 13.9 KiB [emitted] (name: main)
orphan modules 6.09 KiB [orphan] 12 modules
runtime modules 937 bytes 4 modules
cacheable modules 10.8 KiB
./src/index.ts + 6 modules 10.2 KiB [built] [code generated]
./node_modules/typedarray-to-buffer/index.js 646 bytes [built] [code generated]
webpack 5.90.0 compiled successfully in 1753 ms
Starting to build Spin compatible module
Preinitiating using Wizer
Optimizing wasm binary using wasm-opt
Spin compatible module built successfully
Finished building all Spin components
Expected Behaviour
I expected to use the Config import to import secrets defined in the spin.toml file
The text was updated successfully, but these errors were encountered:
Hi @MikeTeddyOmondi , The Spin host functions are only available inside the handler function (handleRequest). The error you run into is because we use wizer to pre-initialize the wasm module and that does not use the spin runtime.
You would also want to use configs inside the function because anything outside will essentially be run only once during build time. Let me know if I can help further.
I encountered an error while building an application with Spin when trying to use the
Config
import from the spin SDK (@fermyon/spin-sdk
)Environment
Linux - Ubuntu 22.04
Spin version - 2.1.0 (f33bb63 2023-12-14)
Source Code
I used the
spin-http-ts
template to generate the projectspin.toml
package.json
index.ts - pulled from this example
Unexpected Behaviour:
The applications builds when the import is removed
Expected Behaviour
I expected to use the
Config
import to import secrets defined in the spin.toml fileThe text was updated successfully, but these errors were encountered: