-
Notifications
You must be signed in to change notification settings - Fork 10.3k
Semi-random JsonException thrown from EndInvokeJS #38962
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Thanks for the detailed investigation on this, @GerkinDev. |
Pretty sure there is more though. But, still, I look forward to the diff with the actual fix and a test case that isolates that situation. I spent a couple of hours trying, and I'm very frustrated. Happy holidays people! 🎅 |
Hmm, so this doesn't seem to be sufficient. I manually evicted the pending task in If we look over at the aspnetcore/src/JSInterop/Microsoft.JSInterop/src/Infrastructure/DotNetDispatcher.cs Lines 288 to 300 in 5c21bfa
Really what that error would indicate is the arguments provided by JS are in the improper format (expected format @GerkinDev I recognize this appears to be a very flaky issue you're having, however any steps which you've taken to reproduce the issue would be helpful here. Without that, we're restricted on how much further we can investigate this issue. Also, if you can let us know what the value of |
Hi @GerkinDev. We have added the "Needs: Author Feedback" label to this issue, which indicates that we have an open question for you before we can take further action. This issue will be closed automatically in 7 days if we do not hear back from you by then - please feel free to re-open it if you come back to this issue after that time. |
Hi, I'm trying to get you this confirmation, along with a record of every calls done to JS invocation tasks creation/deletion. But I'm currently having troubles with the I keep you updated. |
So, I've edited here aspnetcore/src/JSInterop/Microsoft.JSInterop/src/Infrastructure/DotNetDispatcher.cs Line 313 in 591391e
And replaced with throw new JsonException($"Invalid JSON. Arguments were: `{arguments}`"); Here's my exception now:
Below is a record of my calls affecting then Recording[
{
"type": "Start",
"taskId": 2,
"identifier": "console.info"
},
{
"type": "Start with args serialized",
"taskId": 2,
"identifier": "console.info",
"args": "[\"[\",\"15:26:50\",\" \",\"INF\",\"@\",\"ASOMCEWeb.Client.Program\",\"] \",\"Current version: \",\"1.0.1.0\",\"\\n\"]"
},
{
"type": "Start",
"taskId": 3,
"identifier": "console.info"
},
{
"type": "Start with args serialized",
"taskId": 3,
"identifier": "console.info",
"args": "[\"[\",\"15:26:50\",\" \",\"INF\",\"@\",\"ASOMCEWeb.Client.Program\",\"] \",\"Assembly name: \",\"ASOMCEWeb.Client\",\"\\n\"]"
},
{
"type": "Start",
"taskId": 4,
"identifier": "console.error"
},
{
"type": "Start with args serialized",
"taskId": 4,
"identifier": "console.error",
"args": "[\"[\",\"15:26:50\",\" \",\"ERR\",\"@\",\"ASOMCEWeb.Client.Program\",\"] \",\"====== APP STARTED ======\",\"\\n\"]"
},
{
"type": "Start",
"taskId": 5,
"identifier": "console.log"
},
{
"type": "Start with args serialized",
"taskId": 5,
"identifier": "console.log",
"args": "[\"[\",\"15:26:50\",\" \",\"VRB\",\"@\",\"ASOMCEWeb.Client.Program\",\"] \",\"Testing level \",\"Verbose\",\"\\n\"]"
},
{
"type": "Start",
"taskId": 6,
"identifier": "console.log"
},
{
"type": "Start with args serialized",
"taskId": 6,
"identifier": "console.log",
"args": "[\"[\",\"15:26:50\",\" \",\"DBG\",\"@\",\"ASOMCEWeb.Client.Program\",\"] \",\"Testing level \",\"Debug\",\"\\n\"]"
},
{
"type": "Start",
"taskId": 7,
"identifier": "console.info"
},
{
"type": "Start with args serialized",
"taskId": 7,
"identifier": "console.info",
"args": "[\"[\",\"15:26:50\",\" \",\"INF\",\"@\",\"ASOMCEWeb.Client.Program\",\"] \",\"Testing level \",\"Information\",\"\\n\"]"
},
{
"type": "Start",
"taskId": 8,
"identifier": "console.warn"
},
{
"type": "Start with args serialized",
"taskId": 8,
"identifier": "console.warn",
"args": "[\"[\",\"15:26:50\",\" \",\"WRN\",\"@\",\"ASOMCEWeb.Client.Program\",\"] \",\"Testing level \",\"Warning\",\"\\n\"]"
},
{
"type": "Start",
"taskId": 9,
"identifier": "console.error"
},
{
"type": "Start with args serialized",
"taskId": 9,
"identifier": "console.error",
"args": "[\"[\",\"15:26:50\",\" \",\"ERR\",\"@\",\"ASOMCEWeb.Client.Program\",\"] \",\"Testing level \",\"Error\",\"\\n\"]"
},
{
"type": "Start",
"taskId": 10,
"identifier": "console.error"
},
{
"type": "Start with args serialized",
"taskId": 10,
"identifier": "console.error",
"args": "[\"[\",\"15:26:50\",\" \",\"FTL\",\"@\",\"ASOMCEWeb.Client.Program\",\"] \",\"Testing level \",\"Fatal\",\"\\n\"]"
},
{
"type": "Start",
"taskId": 11,
"identifier": "console.info"
},
{
"type": "Start with args serialized",
"taskId": 11,
"identifier": "console.info",
"args": "[\"[\",\"15:26:50\",\" \",\"INF\",\"@\",\"ASOMCEWeb.Client.Program\",\"] \",\"Environment is \",\"Development\",\"\\n\"]"
},
{
"type": "Start",
"taskId": 12,
"identifier": "console.log"
},
{
"type": "Start with args serialized",
"taskId": 12,
"identifier": "console.log",
"args": "[\"[\",\"15:26:50\",\" \",\"DBG\",\"@\",\"ASOMCEWeb.Client.Services.UiPreferencesService\",\"] \",\"Using stored culture \",\"fr-FR\",\"\\n\"]"
},
{
"type": "Start",
"taskId": 13,
"identifier": "console.log"
},
{
"type": "Start with args serialized",
"taskId": 13,
"identifier": "console.log",
"args": "[\"[\",\"15:26:50\",\" \",\"DBG\",\"@\",\"ASOMCEWeb.Client.Services.UiPreferencesService\",\"] \",\"Setting culture \",\"fr-FR\",\"\\n\"]"
},
{
"type": "End",
"taskId": 2,
"succeeded": true,
"existed": false
},
{
"type": "End",
"taskId": 3,
"succeeded": true,
"existed": false
},
{
"type": "End",
"taskId": 4,
"succeeded": true,
"existed": false
},
{
"type": "End",
"taskId": 5,
"succeeded": true,
"existed": false
},
{
"type": "End",
"taskId": 6,
"succeeded": true,
"existed": false
},
{
"type": "End",
"taskId": 7,
"succeeded": true,
"existed": false
},
{
"type": "End",
"taskId": 8,
"succeeded": true,
"existed": false
},
{
"type": "End",
"taskId": 9,
"succeeded": true,
"existed": false
},
{
"type": "End",
"taskId": 10,
"succeeded": true,
"existed": false
},
{
"type": "End",
"taskId": 11,
"succeeded": true,
"existed": false
},
{
"type": "End",
"taskId": 12,
"succeeded": true,
"existed": false
},
{
"type": "End",
"taskId": 13,
"succeeded": true,
"existed": false
},
{
"type": "Start",
"taskId": 2,
"identifier": "Blazor._internal.attachWebRendererInterop"
},
{
"type": "Start with args serialized",
"taskId": 2,
"identifier": "Blazor._internal.attachWebRendererInterop",
"args": "[0,{\"__dotNetObject\":1},{},{}]"
},
{
"type": "Start",
"taskId": 3,
"identifier": "AuthenticationService.init"
},
{
"type": "Start with args serialized",
"taskId": 3,
"identifier": "AuthenticationService.init",
"args": "[{\"configurationEndpoint\":\"_configuration/ASOMCEWeb.Client\"}]"
},
{
"type": "Start",
"taskId": 4,
"identifier": "import"
},
{
"type": "Start with args serialized",
"taskId": 4,
"identifier": "import",
"args": "[\"./_content/BlazorPro.BlazorSize/blazorSizeMediaModule.js\"]"
},
{
"type": "Start",
"taskId": 5,
"identifier": "mudElementRef.getBoundingClientRect"
},
{
"type": "Start with args serialized",
"taskId": 5,
"identifier": "mudElementRef.getBoundingClientRect",
"args": "[{\"__internalId\":\"3\"}]"
},
{
"type": "Start",
"taskId": 6,
"identifier": "mudPopover.connect"
},
{
"type": "Start with args serialized",
"taskId": 6,
"identifier": "mudPopover.connect",
"args": "[\"f66e73d5-f3a7-4618-8da1-712fb87c185c\"]"
},
{
"type": "End",
"taskId": 2,
"succeeded": true,
"existed": true
},
{
"type": "Cleanup",
"taskId": 2,
"existed": true
},
{
"type": "End",
"taskId": 5,
"succeeded": true,
"existed": true
},
{
"type": "Cleanup",
"taskId": 5,
"existed": true
},
{
"type": "Start",
"taskId": 7,
"identifier": "mudResizeListenerFactory.listenForResize"
},
{
"type": "Start with args serialized",
"taskId": 7,
"identifier": "mudResizeListenerFactory.listenForResize",
"args": "[{\"__dotNetObject\":2},{\"reportRate\":100,\"enableLogging\":false,\"suppressInitEvent\":true,\"notifyOnBreakpointOnly\":true,\"breakpointDefinitions\":{\"Xl\":1920,\"Lg\":1280,\"Md\":960,\"Sm\":600,\"Xs\":0}},\"6476f815-2999-46cc-bcfa-23b7c280d6a1\"]"
},
{
"type": "End",
"taskId": 6,
"succeeded": true,
"existed": true
},
{
"type": "Cleanup",
"taskId": 6,
"existed": true
},
{
"type": "Start",
"taskId": 8,
"identifier": "mudPopover.initilize"
},
{
"type": "Start with args serialized",
"taskId": 8,
"identifier": "mudPopover.initilize",
"args": "[\"mudblazor-main-content\",0]"
},
{
"type": "End",
"taskId": 7,
"succeeded": true,
"existed": true
},
{
"type": "Cleanup",
"taskId": 7,
"existed": true
},
{
"type": "Start",
"taskId": 9,
"identifier": "mudResizeListener.getBrowserWindowSize"
},
{
"type": "Start with args serialized",
"taskId": 9,
"identifier": "mudResizeListener.getBrowserWindowSize",
"args": null
},
{
"type": "End",
"taskId": 8,
"succeeded": true,
"existed": true
},
{
"type": "Cleanup",
"taskId": 8,
"existed": true
},
{
"type": "End",
"taskId": 9,
"succeeded": true,
"existed": true
},
{
"type": "Cleanup",
"taskId": 9,
"existed": true
},
{
"type": "Start",
"taskId": 10,
"identifier": "mudElementRef.addEventListener"
},
{
"type": "Start with args serialized",
"taskId": 10,
"identifier": "mudElementRef.addEventListener",
"args": "[{\"__internalId\":\"2\"},{\"__dotNetObject\":3},\"mouseenter\",\"OnMouseEnter\",[],true]"
},
{
"type": "End",
"taskId": 10,
"succeeded": true,
"existed": true
},
{
"type": "Cleanup",
"taskId": 10,
"existed": true
},
{
"type": "Start",
"taskId": 11,
"identifier": "mudElementRef.addEventListener"
},
{
"type": "Start with args serialized",
"taskId": 11,
"identifier": "mudElementRef.addEventListener",
"args": "[{\"__internalId\":\"2\"},{\"__dotNetObject\":3},\"mouseleave\",\"OnMouseLeave\",[],true]"
},
{
"type": "End",
"taskId": 11,
"succeeded": true,
"existed": true
},
{
"type": "Cleanup",
"taskId": 11,
"existed": true
},
{
"type": "End",
"taskId": 3,
"succeeded": true,
"existed": true
},
{
"type": "Cleanup",
"taskId": 3,
"existed": true
},
{
"type": "Start",
"taskId": 12,
"identifier": "AuthenticationService.getUser"
},
{
"type": "Start with args serialized",
"taskId": 12,
"identifier": "AuthenticationService.getUser",
"args": null
},
{
"type": "End",
"taskId": 4,
"succeeded": true,
"existed": true
},
{
"type": "Cleanup",
"taskId": 4,
"existed": true
},
{
"type": "Start",
"taskId": 13,
"identifier": "addMediaQueryList"
},
{
"type": "Start with args serialized",
"taskId": 13,
"identifier": "addMediaQueryList",
"args": "[{\"__dotNetObject\":4}]"
},
{
"type": "End",
"taskId": 13,
"succeeded": true,
"existed": true
},
{
"type": "Cleanup",
"taskId": 13,
"existed": true
},
{
"type": "Start",
"taskId": 14,
"identifier": "addMediaQueryToList"
},
{
"type": "Start with args serialized",
"taskId": 14,
"identifier": "addMediaQueryToList",
"args": "[{\"__dotNetObject\":4},\"(min-width: 1280px)\"]"
},
{
"type": "End",
"taskId": 14,
"succeeded": true,
"existed": true
},
{
"type": "Cleanup",
"taskId": 14,
"existed": true
},
{
"type": "End",
"taskId": 12,
"succeeded": true,
"existed": true
},
{
"type": "Cleanup",
"taskId": 12,
"existed": true
},
{
"type": "Start",
"taskId": 14,
"identifier": "console.log"
},
{
"type": "Start with args serialized",
"taskId": 14,
"identifier": "console.log",
"args": "[\"[\",\"15:27:18\",\" \",\"VRB\",\"@\",\"ASOMCEWeb.Client.Services.AppAccessToken.AccessTokenProviderViaCached\",\"] \",\"Start getting access token right now\",\"\\n\",\"MCE\"]"
},
{
"type": "Start",
"taskId": 15,
"identifier": "sessionStorage.getItem"
},
{
"type": "Start with args serialized",
"taskId": 15,
"identifier": "sessionStorage.getItem",
"args": "[\"Microsoft.AspNetCore.Components.WebAssembly.Authentication.CachedAuthSettings\"]"
},
{
"type": "Start",
"taskId": 15,
"identifier": "console.log"
},
{
"type": "Start with args serialized",
"taskId": 15,
"identifier": "console.log",
"args": "[\"[\",\"15:27:18\",\" \",\"DBG\",\"@\",\"ASOMCEWeb.Client.Services.SignalRStateMonitorService\",\"] \",\"Hub \",\"MCE\",\" went from \",null,\" to \",\"Pending\",\" (mapped from \",\"Pending\",\")}\",\"\\n\",\"MCE\"]"
},
{
"type": "Start",
"taskId": 16,
"identifier": "console.log"
},
{
"type": "Start with args serialized",
"taskId": 16,
"identifier": "console.log",
"args": "[\"[\",\"15:27:18\",\" \",\"VRB\",\"@\",\"ASOMCEWeb.Client.Services.IncrementalProviderV2.RealProviders.Mce.IncrementalMceProvider\",\"] \",\"Resync scheduled\",\"\\n\",\"MCE\"]"
},
{
"type": "End",
"taskId": 14,
"succeeded": true,
"existed": false
},
{
"type": "End",
"taskId": 15,
"succeeded": true,
"existed": true
},
{
"type": "Cleanup",
"taskId": 15,
"existed": true
},
{
"type": "Start",
"taskId": 16,
"identifier": "sessionStorage.getItem"
},
{
"type": "Start with args serialized",
"taskId": 16,
"identifier": "sessionStorage.getItem",
"args": "[\"oidc.user:https://localhost:5001:ASOMCEWeb.Client\"]"
},
{
"type": "End",
"taskId": 15,
"succeeded": true,
"existed": false
},
{
"type": "End",
"taskId": 16,
"succeeded": true,
"existed": true
},
{
"type": "Cleanup",
"taskId": 16,
"existed": true
},
{
"type": "Start",
"taskId": 17,
"identifier": "console.log"
},
{
"type": "Start with args serialized",
"taskId": 17,
"identifier": "console.log",
"args": "[\"[\",\"15:27:18\",\" \",\"DBG\",\"@\",\"ASOMCEWeb.Client.Services.AppAccessToken.AccessTokenProviderViaCached\",\"] \",\"Failed to read token from storage. Tries: \",1,\"\\n\",\"ASOMCEWeb.Client.Services.AppAccessToken.AccessTokenProviderViaCached\\u002BMissingStorageItemException: Missing storage key \\u0022oidc.user:https://localhost:5001:ASOMCEWeb.Client\\u0022\\n at ASOMCEWeb.Client.Services.AppAccessToken.AccessTokenProviderViaCached._GetAccessTokenFromStorage() in F:\\\\Work\\\\cs\\\\ASOMCEWeb\\\\ASOMCEWeb\\\\Client\\\\Services\\\\AppAccessToken\\\\AccessTokenProviderViaCached.cs:line 68\\n at ASOMCEWeb.Client.Services.AppAccessToken.AccessTokenProviderViaCached.GetAccessToken() in F:\\\\Work\\\\cs\\\\ASOMCEWeb\\\\ASOMCEWeb\\\\Client\\\\Services\\\\AppAccessToken\\\\AccessTokenProviderViaCached.cs:line 102\",\"MCE\"]"
},
{
"type": "End",
"taskId": 16,
"succeeded": true,
"existed": false
},
{
"type": "End",
"taskId": 17,
"succeeded": true,
"existed": false
},
{
"type": "Start",
"taskId": 18,
"identifier": "console.log"
},
{
"type": "Start with args serialized",
"taskId": 18,
"identifier": "console.log",
"args": "[\"[\",\"15:27:18\",\" \",\"DBG\",\"@\",\"ASOMCEWeb.Client.Services.IncrementalProviderV2.RealProviders.Mce.IncrementalMceProvider\",\"] \",\"Resync started\",\"\\n\",\"MCE\"]"
},
{
"type": "Start",
"taskId": 17,
"identifier": "mudElementRef.getBoundingClientRect"
},
{
"type": "Start with args serialized",
"taskId": 17,
"identifier": "mudElementRef.getBoundingClientRect",
"args": "[{\"__internalId\":\"7\"}]"
},
{
"type": "Start",
"taskId": 18,
"identifier": "mudElementRef.getBoundingClientRect"
},
{
"type": "Start with args serialized",
"taskId": 18,
"identifier": "mudElementRef.getBoundingClientRect",
"args": "[{\"__internalId\":\"9\"}]"
},
{
"type": "End",
"taskId": 18,
"succeeded": true,
"existed": true
},
{
"type": "Cleanup",
"taskId": 18,
"existed": true
},
{
"type": "Start",
"taskId": 19,
"identifier": "mudElementRef.addEventListener"
},
{
"type": "Start with args serialized",
"taskId": 19,
"identifier": "mudElementRef.addEventListener",
"args": "[{\"__internalId\":\"8\"},{\"__dotNetObject\":5},\"animationend\",\"AnimationEnd\",[],false]"
},
{
"type": "End",
"taskId": 17,
"succeeded": true,
"existed": true
},
{
"type": "Cleanup",
"taskId": 17,
"existed": true
},
{
"type": "Start",
"taskId": 20,
"identifier": "mudElementRef.addEventListener"
},
{
"type": "Start with args serialized",
"taskId": 20,
"identifier": "mudElementRef.addEventListener",
"args": "[{\"__internalId\":\"6\"},{\"__dotNetObject\":6},\"animationend\",\"AnimationEnd\",[],false]"
},
{
"type": "End",
"taskId": 18,
"succeeded": true,
"existed": false
}
]
Records were done just above the following lines:
Please don't pay attention to the dirty calls I made to fetch token from session storage manually. Using the normal authentication service triggered an error almost every time, and now that I'm thinking about it, it might be related to this issue too. But I left those calls in the record above so that you can see every calls made. So I think that the error is that Let me know your thoughts if you have a couple of minutes :) |
Thanks for the detailed analysis @GerkinDev! Just to clarify on your recording: {
"type": "Start",
"taskId": 18,
"identifier": "console.log"
},
{
"type": "Start with args serialized",
"taskId": 18,
"identifier": "console.log",
"args": "[\"[\",\"15:27:18\",\" \",\"DBG\",\"@\",\"ASOMCEWeb.Client.Services.IncrementalProviderV2.RealProviders.Mce.IncrementalMceProvider\",\"] \",\"Resync started\",\"\\n\",\"MCE\"]"
},
...,
{
"type": "Start",
"taskId": 18,
"identifier": "mudElementRef.getBoundingClientRect"
},
{
"type": "Start with args serialized",
"taskId": 18,
"identifier": "mudElementRef.getBoundingClientRect",
"args": "[{\"__internalId\":\"9\"}]"
}, Based on the identifier it appears there are two distinct tasks with |
Wow, indeed, I didn't even noticed that ! Here is the full replacement: internal ValueTask<TValue> InvokeAsync<[DynamicallyAccessedMembers(JsonSerialized)] TValue>(
long targetInstanceId,
string identifier,
CancellationToken cancellationToken,
object?[]? args)
{
var taskId = Interlocked.Increment(ref _nextPendingTaskId);
var tcs = new TaskCompletionSource<TValue>();
if (cancellationToken.CanBeCanceled)
{
_cancellationRegistrations[taskId] = cancellationToken.Register(() =>
{
tcs.TrySetCanceled(cancellationToken);
CleanupTasksAndRegistrations(taskId);
});
}
TasksRecord.Add(new
{
type = "Start",
taskId = taskId,
identifier = identifier,
});
_pendingTasks[taskId] = tcs;
try
{
if (cancellationToken.IsCancellationRequested)
{
tcs.TrySetCanceled(cancellationToken);
CleanupTasksAndRegistrations(taskId);
return new ValueTask<TValue>(tcs.Task);
}
var argsJson = args is not null && args.Length != 0 ?
JsonSerializer.Serialize(args, JsonSerializerOptions) :
null;
TasksRecord.Add(new
{
type = "Start with args serialized",
taskId = taskId,
identifier = identifier,
args = argsJson
});
var resultType = JSCallResultTypeHelper.FromGeneric<TValue>();
BeginInvokeJS(taskId, identifier, argsJson, resultType, targetInstanceId);
return new ValueTask<TValue>(tcs.Task);
}
catch
{
CleanupTasksAndRegistrations(taskId);
throw;
}
} |
|
Yes, you are absolutely right on the whole thing, I did the record without thread safety in mind at all, and I indeed made it static because I wasn't sure how I could get its content back. So i tried silly stuff. Hey don't look at me like that, I'm not a C# expert okay ? I'm just a poor front-end JS aficionado that had a work on Blazor ! Enough talking. Here is the exact same recording made with an instance-bound BlockingCollection: Instance recording with blocking collection[
{
"type": "End",
"taskId": 2,
"succeeded": true,
"existed": false
},
{
"type": "End",
"taskId": 3,
"succeeded": true,
"existed": false
},
{
"type": "End",
"taskId": 4,
"succeeded": true,
"existed": false
},
{
"type": "End",
"taskId": 5,
"succeeded": true,
"existed": false
},
{
"type": "End",
"taskId": 6,
"succeeded": true,
"existed": false
},
{
"type": "End",
"taskId": 7,
"succeeded": true,
"existed": false
},
{
"type": "End",
"taskId": 8,
"succeeded": true,
"existed": false
},
{
"type": "End",
"taskId": 9,
"succeeded": true,
"existed": false
},
{
"type": "End",
"taskId": 10,
"succeeded": true,
"existed": false
},
{
"type": "End",
"taskId": 11,
"succeeded": true,
"existed": false
},
{
"type": "End",
"taskId": 12,
"succeeded": true,
"existed": false
},
{
"type": "End",
"taskId": 13,
"succeeded": true,
"existed": false
},
{
"type": "Start",
"taskId": 2,
"identifier": "Blazor._internal.attachWebRendererInterop"
},
{
"type": "Start with args serialized",
"taskId": 2,
"identifier": "Blazor._internal.attachWebRendererInterop",
"args": "[0,{\"__dotNetObject\":1},{},{}]"
},
{
"type": "Start",
"taskId": 3,
"identifier": "AuthenticationService.init"
},
{
"type": "Start with args serialized",
"taskId": 3,
"identifier": "AuthenticationService.init",
"args": "[{\"configurationEndpoint\":\"_configuration/ASOMCEWeb.Client\"}]"
},
{
"type": "Start",
"taskId": 4,
"identifier": "import"
},
{
"type": "Start with args serialized",
"taskId": 4,
"identifier": "import",
"args": "[\"./_content/BlazorPro.BlazorSize/blazorSizeMediaModule.js\"]"
},
{
"type": "Start",
"taskId": 5,
"identifier": "mudElementRef.getBoundingClientRect"
},
{
"type": "Start with args serialized",
"taskId": 5,
"identifier": "mudElementRef.getBoundingClientRect",
"args": "[{\"__internalId\":\"3\"}]"
},
{
"type": "Start",
"taskId": 6,
"identifier": "mudPopover.connect"
},
{
"type": "Start with args serialized",
"taskId": 6,
"identifier": "mudPopover.connect",
"args": "[\"e511a23a-683e-41a6-98fd-af4acff9a464\"]"
},
{
"type": "End",
"taskId": 2,
"succeeded": true,
"existed": true
},
{
"type": "Cleanup",
"taskId": 2,
"existed": true
},
{
"type": "End",
"taskId": 5,
"succeeded": true,
"existed": true
},
{
"type": "Cleanup",
"taskId": 5,
"existed": true
},
{
"type": "Start",
"taskId": 7,
"identifier": "mudResizeListenerFactory.listenForResize"
},
{
"type": "Start with args serialized",
"taskId": 7,
"identifier": "mudResizeListenerFactory.listenForResize",
"args": "[{\"__dotNetObject\":2},{\"reportRate\":100,\"enableLogging\":false,\"suppressInitEvent\":true,\"notifyOnBreakpointOnly\":true,\"breakpointDefinitions\":{\"Xl\":1920,\"Lg\":1280,\"Md\":960,\"Sm\":600,\"Xs\":0}},\"cd29314b-1cdf-4b39-8540-d5b03884f01d\"]"
},
{
"type": "End",
"taskId": 6,
"succeeded": true,
"existed": true
},
{
"type": "Cleanup",
"taskId": 6,
"existed": true
},
{
"type": "Start",
"taskId": 8,
"identifier": "mudPopover.initilize"
},
{
"type": "Start with args serialized",
"taskId": 8,
"identifier": "mudPopover.initilize",
"args": "[\"mudblazor-main-content\",0]"
},
{
"type": "End",
"taskId": 7,
"succeeded": true,
"existed": true
},
{
"type": "Cleanup",
"taskId": 7,
"existed": true
},
{
"type": "Start",
"taskId": 9,
"identifier": "mudResizeListener.getBrowserWindowSize"
},
{
"type": "Start with args serialized",
"taskId": 9,
"identifier": "mudResizeListener.getBrowserWindowSize",
"args": null
},
{
"type": "End",
"taskId": 8,
"succeeded": true,
"existed": true
},
{
"type": "Cleanup",
"taskId": 8,
"existed": true
},
{
"type": "End",
"taskId": 9,
"succeeded": true,
"existed": true
},
{
"type": "Cleanup",
"taskId": 9,
"existed": true
},
{
"type": "Start",
"taskId": 10,
"identifier": "mudElementRef.addEventListener"
},
{
"type": "Start with args serialized",
"taskId": 10,
"identifier": "mudElementRef.addEventListener",
"args": "[{\"__internalId\":\"2\"},{\"__dotNetObject\":3},\"mouseenter\",\"OnMouseEnter\",[],true]"
},
{
"type": "End",
"taskId": 10,
"succeeded": true,
"existed": true
},
{
"type": "Cleanup",
"taskId": 10,
"existed": true
},
{
"type": "Start",
"taskId": 11,
"identifier": "mudElementRef.addEventListener"
},
{
"type": "Start with args serialized",
"taskId": 11,
"identifier": "mudElementRef.addEventListener",
"args": "[{\"__internalId\":\"2\"},{\"__dotNetObject\":3},\"mouseleave\",\"OnMouseLeave\",[],true]"
},
{
"type": "End",
"taskId": 11,
"succeeded": true,
"existed": true
},
{
"type": "Cleanup",
"taskId": 11,
"existed": true
},
{
"type": "End",
"taskId": 3,
"succeeded": true,
"existed": true
},
{
"type": "Cleanup",
"taskId": 3,
"existed": true
},
{
"type": "Start",
"taskId": 12,
"identifier": "AuthenticationService.getUser"
},
{
"type": "Start with args serialized",
"taskId": 12,
"identifier": "AuthenticationService.getUser",
"args": null
},
{
"type": "End",
"taskId": 4,
"succeeded": true,
"existed": true
},
{
"type": "Cleanup",
"taskId": 4,
"existed": true
},
{
"type": "Start",
"taskId": 13,
"identifier": "addMediaQueryList"
},
{
"type": "Start with args serialized",
"taskId": 13,
"identifier": "addMediaQueryList",
"args": "[{\"__dotNetObject\":4}]"
},
{
"type": "End",
"taskId": 13,
"succeeded": true,
"existed": true
},
{
"type": "Cleanup",
"taskId": 13,
"existed": true
},
{
"type": "Start",
"taskId": 14,
"identifier": "addMediaQueryToList"
},
{
"type": "Start with args serialized",
"taskId": 14,
"identifier": "addMediaQueryToList",
"args": "[{\"__dotNetObject\":4},\"(min-width: 1280px)\"]"
},
{
"type": "End",
"taskId": 14,
"succeeded": true,
"existed": true
},
{
"type": "Cleanup",
"taskId": 14,
"existed": true
},
{
"type": "End",
"taskId": 12,
"succeeded": true,
"existed": true
},
{
"type": "Cleanup",
"taskId": 12,
"existed": true
},
{
"type": "Start",
"taskId": 15,
"identifier": "sessionStorage.getItem"
},
{
"type": "Start with args serialized",
"taskId": 15,
"identifier": "sessionStorage.getItem",
"args": "[\"Microsoft.AspNetCore.Components.WebAssembly.Authentication.CachedAuthSettings\"]"
},
{
"type": "End",
"taskId": 14,
"succeeded": true,
"existed": false
},
{
"type": "End",
"taskId": 15,
"succeeded": true,
"existed": true
},
{
"type": "Cleanup",
"taskId": 15,
"existed": true
},
{
"type": "Start",
"taskId": 16,
"identifier": "sessionStorage.getItem"
},
{
"type": "Start with args serialized",
"taskId": 16,
"identifier": "sessionStorage.getItem",
"args": "[\"oidc.user:https://localhost:5001:ASOMCEWeb.Client\"]"
},
{
"type": "End",
"taskId": 15,
"succeeded": true,
"existed": false
},
{
"type": "End",
"taskId": 16,
"succeeded": true,
"existed": true
},
{
"type": "Cleanup",
"taskId": 16,
"existed": true
},
{
"type": "End",
"taskId": 16,
"succeeded": true,
"existed": false
},
{
"type": "End",
"taskId": 17,
"succeeded": true,
"existed": false
},
{
"type": "Start",
"taskId": 17,
"identifier": "mudElementRef.getBoundingClientRect"
},
{
"type": "Start with args serialized",
"taskId": 17,
"identifier": "mudElementRef.getBoundingClientRect",
"args": "[{\"__internalId\":\"7\"}]"
},
{
"type": "Start",
"taskId": 18,
"identifier": "mudElementRef.getBoundingClientRect"
},
{
"type": "Start with args serialized",
"taskId": 18,
"identifier": "mudElementRef.getBoundingClientRect",
"args": "[{\"__internalId\":\"9\"}]"
},
{
"type": "End",
"taskId": 18,
"succeeded": true,
"existed": true
},
{
"type": "Cleanup",
"taskId": 18,
"existed": true
},
{
"type": "Start",
"taskId": 19,
"identifier": "mudElementRef.addEventListener"
},
{
"type": "Start with args serialized",
"taskId": 19,
"identifier": "mudElementRef.addEventListener",
"args": "[{\"__internalId\":\"8\"},{\"__dotNetObject\":5},\"animationend\",\"AnimationEnd\",[],false]"
},
{
"type": "End",
"taskId": 17,
"succeeded": true,
"existed": true
},
{
"type": "Cleanup",
"taskId": 17,
"existed": true
},
{
"type": "Start",
"taskId": 20,
"identifier": "mudElementRef.addEventListener"
},
{
"type": "Start with args serialized",
"taskId": 20,
"identifier": "mudElementRef.addEventListener",
"args": "[{\"__internalId\":\"6\"},{\"__dotNetObject\":6},\"animationend\",\"AnimationEnd\",[],false]"
},
{
"type": "End",
"taskId": 18,
"succeeded": true,
"existed": false
}
] Also, I precise that both records JSON are taken at the moment where the exception is being thrown |
Thanks, this is great! I think I see the issue now, and your suggestion to use If you're able to reproduce the issue, could you please try out that branch ( |
Good news ! It seems that it fixed the main issue ! Now, the surprise is to see if it solved also other errors scattered around my project :) good job and thank you very much :) hope this gets approved soon ! |
Describe the bug
In some random cases, Blazor JSInterop throws JsonExceptions. I didn't find a way to create a minimal reproduction, since this appears to be a timing issue which is super hard to reproduce. Moreover, it happens at different points on my versions of Chrome & Firefox, and changes (pass on one page previously failing, & fail on page previously passing) depending on
Task.Delay()
s.So, yeah, a repro gonna be hard. Yet, I think I could give you access to my full app where the error occurs.
This is probably a continuation of #34267
So I've tweaked around, cloned aspnetcore entierly & built it locally to test some little things. And I've managed to track it down to this:
My error was thrown here:
aspnetcore/src/JSInterop/Microsoft.JSInterop/src/Infrastructure/DotNetDispatcher.cs
Lines 311 to 314 in ae1a6cb
I've found out that an entire JSON object was still pending for read in the JsonReader.
So I've digged deeper to here:
aspnetcore/src/JSInterop/Microsoft.JSInterop/src/JSRuntime.cs
Lines 228 to 235 in ae1a6cb
So, if the invocation timed out (or whatever, but yet, the task is not there anymore), the stream is let as-is, untouched, with data pending.
I've managed to reliably fix my issue by adding
jsonReader.Skip()
before here:aspnetcore/src/JSInterop/Microsoft.JSInterop/src/JSRuntime.cs
Line 234 in ae1a6cb
I don't know if it makes sense. I don't have a repro, but at least, you might have more clue about the underlying problem.
To Reproduce
Exceptions (if any)
Further technical details
dotnet --info
:dotnet --info Output
The text was updated successfully, but these errors were encountered: