I got the same problem as @Amandeep Singh in comment with the actual solution, but i found a workaround.
I'm converting the image to dataUrl immediately after loading :
fabric.Image.fromURL(url).then((img) => {
img.src = img.toDataURL();
canvas.add(img);
canvas.renderAll(); // i need this to refresh the canvas in fabricjs 6 in my case
});
And by converting the image at loading, no need to extend toObject of fabric.Image