Incomprehensible error with StreamPeerGZIP.finish()

Godot Version

4.2.1

Question

Using StreamPeerGZIP to compress a string and calling .finish() gets me an error message that I can’t resolve (and don’t really understand to be honest)

SaveControl.gd:75 @ gzip_encode(): Condition "err != (p_close ? 1 : 0)" is true. Returning: FAILED

here’s the code I have :

func gzip_encode(text: String):
	var gzip = StreamPeerGZIP.new()
	gzip.start_compression()
	gzip.put_data(text.to_utf8_buffer())
	gzip.finish()
	return gzip.get_data(gzip.get_available_bytes())

expanding the buffer size or using deflate = true in .start_compression() didn’t change the error
Thanks

It may be an engine bug. Open an issue here Issues · godotengine/godot · GitHub explaining the problem and attaching a minimal reproduction project.