replace_contents_bytes_async doesn't work when promisified
System information
What is your operating system and version? Fedora 37
What is your version of GJS? 1.74.1
Bug information
Steps to reproduce
Doesn't work:
Gio._promisify(Gio.File.prototype,
'replace_contents_bytes_async',
'replace_contents_finish');
// get Gio.file from somewhere, e.g. file picker
await file.replace_contents_bytes_async( // <--- the app hangs here
new GLib.Bytes('abc'),
null,
false,
FileCreateFlags.REPLACE_DESTINATION);
Works:
// get Gio.file from somewhere, e.g. file picker
await new Promise((resolve, reject) => {
file.replace_contents_bytes_async(
new GLib.Bytes('abc'),
null,
false,
Gio.FileCreateFlags.REPLACE_DESTINATION,
null,
(file_, result) => {
try {
resolve(file.replace_contents_finish(result));
} catch (e) {
reject(e);
}
}
);
});
Current behaviour
The code just hangs on the awaited call, and never returns.
The longer version with new Promise(...)
works correctly.
Expected behaviour
I'd expect the version that uses Promise Helper to work properly as well.