title: JSRuntime.InvokeVoidAsync in Blazor Server app calling multiple functions when I only tell it to call one
body: <p>I have a Blazor server app with two buttons. The first button calls the <code>MenuOpen</code> method in C#, and the second calls the <code>TestJSInterop</code> method in C#. Here is the code:</p>
  
  <pre><code>@inject IJSRuntime JSRuntime;
  
  &lt;!-- buttons --&gt;
  
  @code {
      List&lt;int&gt; tabs = new List&lt;int&gt;();
  
      protected override Task OnAfterRenderAsync(bool firstRender)
      {
          JSRuntime.InvokeVoidAsync("monacoInit");
          return base.OnAfterRenderAsync(firstRender);
      }
  
      async Task OpenNewTab(string title)
      {
          int newId = await JSRuntime.InvokeAsync&lt;int&gt;("addEditorModel", new object[]
          {
              title, "test", "test", "test"
          });
          tabs.Add(newId);
          await JSRuntime.InvokeVoidAsync("addTab", newId);
      }
  
      async Task MenuOpen()
      {
          await OpenNewTab("testing");
      }
  
      async Task TestJSInterop()
      {
          await JSRuntime.InvokeVoidAsync("console.log", "test");
      }
  }
  </code></pre>
  
  <p>In the Javascript, I've added <code>console.log</code>s to each method that's being called from C#. When I press the button to call <code>TestJSInterop</code>, I get the following result in the console:</p>
  
  <blockquote>
    <p>test</p>
    
    <p>call addEditorModel</p>
    
    <p>call addTab: parameter is 0</p>
    
    <p>call addEditorModel</p>
    
    <p>call addTab: parameter is 0</p>
  </blockquote>
  
  <p>When I press the button to call <code>MenuOpen</code>, I get this result:</p>
  
  <blockquote>
    <p>call addEditorModel</p>
    
    <p>call addTab: parameter is 1</p>
    
    <p>call addEditorModel</p>
    
    <p>call addTab: parameter is 0</p>
    
    <p>call addEditorModel</p>
    
    <p>call addTab: parameter is 0</p>
  </blockquote>
  
  <p>I know that the <code>OpenNewTab</code> C# method is not being called multiple times, as when I put a breakpoint there and click the button to call <code>TestJSInterop</code> I do not reach the breakpoint.</p>
  
  <p>The <code>JSRuntime.InvokeVoidAsync</code> call does work correctly in <code>OnAfterRenderAsync</code>. </p>
  
  <p>Why am I getting this behavior?</p>