WebAssembly / wasi-clocks

Clocks API for WASI
40 stars 14 forks source link

What's the approach to report errors? #62

Closed loganek closed 8 months ago

loganek commented 8 months ago

Do apologize if that was already discussed, but couldn't find it. How should the runtime report an error in case it can't handle the call? e.g. wall clock might not be supported on some of the exotic platforms, but they might have access to a monotonic clock. How should the platform communicate the lack of one of the clocks? In preview1 the function could return an error, but in preview2 I see the return value from the now() function is just an uint64, not a Result type.

Thanks

sunfishcode commented 8 months ago

On an exotic platform with no underlying clock, it's ok to have a wasi-clocks that always returns the same time evern time (as if the computer is just really fast :wink:). If the user subscribes to a timeout, the clock could just immediately update its time to the timeout value and notify the timeout immediately.

But yes, it is infallible, because that simplifies using it in most scenarios, as clocks effectively don't fail dynamically.

loganek commented 8 months ago

Yeah, agree the clock shouldn't fail at runtime, the question was more about lack of the functionality. I guess returning constant is a good workaround for me.

Thanks for the quick reply.