ErrRuntime_WeakMapInvalidKey Causes Full Crash Of Game

Summary

I believe this is a bug and can be solved internally by having a method fail silently/with a log report instead of crashing a whole game. A think there was a similar bug report filed months ago when verse persistence came out, but I can’t find it so I’m filing a new bug.

This particular problem happens if you try to access the weak map of verse persistence and the player has already left the game. This is a very common issue and I understand that for own verse coding we should be verifying the fort character is valid, but if for some reason it goes through the game will still full crash with this log report:

Verse unrecoverable error: ErrRuntime_WeakMapInvalidKey: Invalid key used to access persistent var weak_map. (Invalid key used to access persistent var weak_map.)

My request is that this be handled internally so that the game doesn’t full crash.

Please select what you are reporting on:

Verse

What Type of Bug are you experiencing?

Verse

Steps to Reproduce

Just create some verse persistence weak map, add a player to it with player data (can be anything, one simple value is fine of PlayerID or something being an int). Then instantiate that upon spawn, try to update it after the player has left the map. The map should full crash.

Expected Result

I expect verse to continue to run and not crash completely destroying a whole lobby of players still in the game.

Observed Result

Game crashes and everybody has to leave that lobby.

Platform(s)

pc

hi @GraemeBB ,
The way around this problem is to use the

<decides><transacts> 

In your function with an

if (conditions) { … }
#this sort of persistence code is replaced by the <decides><transacts>  below
var PlayerProfileDataMap:weak_map(player, player_profile_data) = map{}

# This code checks the variable using rollback
IsPuzzleSolved()<decides><transacts> : void =
    CurrentState = PlayerProfileDataMap

 # succeeds if CurrentState is equal to PuzzleSolution, and fails if not
if (IsPuzzleSolved()) { … }

This is template code made from the Verse Persistence documentation where

Inside the block is the code for accessing the persistence weak_map variable.

<decides><transacts> 

prevents the Verse runtime error

This code comes from
Verse Failure Contexts

Dealing with VersePersistence weak_map

Previously posted about this in another post
I want to know under what conditions this error occurs in Verse

This another post that may be useful
What happens when verse runtime error occurs

I appreciate that, thank you! I still think though that such a crash shouldn’t happen and is reminiscent of the GetTransform() crash that used to happen and they fixed. I don’t think anything at all should full crash a game and this does, so it seems like something to look into.

I do appreciate the further insight into what causes it though, thanks for taking the time to let me know that.

1 Like

A epic dev in a old post on the forums said that the feature to use player data without them needing to exist in the playspace was going to be implemented but right now it throws a verse runtime error instead of you not be able to compile the code. I think it has something to do with forward compatible and that they don’t want to use failure for a feature that will be implemented. So right now you need to check if the Player.IsActive fails or not.

1 Like