dotnet / dotnet/fsharp

Support F# Kernel (dotnet-interactive) on Wasm

Open
#16,881 20 comments 0 reactions 0 assignees View on GitHub
Area-FSI Feature Request help wanted
Dominant language
F#
Stars
4.3k
Forks
876
Avg merge
4d 11h
Merged PRs (30d)
131

Description

Edited: I describe the wanted feature for F# Kernel in dotnet interactive but the message of not supported operation seems to come from the standard F# scripting tools, hence I asked it first here

**Is your feature request related to a problem? Please describe.**

Dotnet Interactive is an amazing tool that is used within Polyglot Notebook extension for VS Code.

It is still pretty versatile and extendable so I have played with it from the early beginning and was able to write interesting kernel extensions.

But I always wanted to have the opportunity to write sth that is built around it from top to bottom, including a custom code editor that executes a lot of my F# DSL code behind the scenes.

I was able to create a PoC that works with Blazor but only on a server mode.
It has a lot of limitations and burdens like supporting multiple users in an isolated and performant manner.

**Describe the solution you'd like**

I would like to move the custom code editor that runs dotnet-interactive F# kernel to the client with webassembly.
Previously (<= 8.0.0) the same code that runs in a server mode was hanging in a webassembly mode:

![image](https://github.com/dotnet/fsharp/assets/162319990/1fb0294a-5405-46c3-8906-7e9c30f9a1c5)

"Requested value for x" message was never displayed, there were no single error in the console as well

I got a brief suggestion from dotnet-interactive team that it maybe a result of lacking mutlithreading support with webassembly and I gave up for a while.

At the beginning of this year I noticed that a real multithreading for Blazor is planned to go with .NET 9(https://github.com/dotnet/aspnetcore/issues/17730)

Despite the fact it has just been marked as tentative due to some several discovered challenges, there is an ongoing work on it.

And if fact with .NET 9 preview-1 I noticed that the code no longer hangs but just fails and with recent .NET 9 preview-2 the exact error is much more clear.

The RequestValue command produces CommandFailed event with the message:

**System.PlatformNotSupportedException: Operation is not supported on this platform.**

![image](https://github.com/dotnet/fsharp/assets/162319990/58484a60-0368-4bf6-aff2-7c9fee27e810)

The native code that it complains is below, not sure if it provide any correct direction thought
![image](https://github.com/dotnet/fsharp/assets/162319990/ecb6e789-b5d1-4bde-830e-f37041be3a13)

Do you have any first impressions about the problematic code ?
Is it something that is possible to resolve ?
Does it display the real cause or the message is misleading ?

@KevinRansom @vzarytovskii @dsyme @T-Gro @colombod @jonsequitur

Also tried the same with CSharpKernel but it fails early on kernel creation with no message so F# goes much further here.

Let's assume this problem is manageable, I'm obviously not sure what will happen further, as the work on multithreading support is on an early stage.

I believe that using Nuget packages maybe an issue in WebAssembly (although I do not necessarily require it in my case)
Can you spot other possible endeavours ?

**Describe alternatives you've considered**

none

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.