Skip to content

errorWidget seems to leak exceptions occasionallyΒ #780

Description

@larssn

πŸ› Bug Report

I keep getting http exceptions in my debug console and error reporting service (Sentry), which shouldn't happen as I use the errorWidget builder.
The exceptions look like this:

I/flutter (14804): ══║ EXCEPTION CAUGHT BY IMAGE RESOURCE SERVICE β•žβ•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•
I/flutter (14804): The following HttpExceptionWithStatus was thrown resolving an image codec:
I/flutter (14804): HttpException: Invalid statusCode: 403, uri = <redacted>
I/flutter (14804):
I/flutter (14804): When the exception was thrown, this was the stack
I/flutter (14804):
I/flutter (14804): Image provider:
I/flutter (14804): CachedNetworkImageProvider("<redacted>",
I/flutter (14804): scale: 1.0)
I/flutter (14804):  Image key:
I/flutter (14804): CachedNetworkImageProvider("<redacted>",
I/flutter (14804): scale: 1.0):
I/flutter (14804):   CachedNetworkImageProvider("<redacted>",
I/flutter (14804):   scale: 1.0)
I/flutter (14804): ════════════════════════════════════════════════════════════════════════════════════════════════════

The widget is used like this:

final uri = "https://firebasestorage.googleapis.com/v0/b/test-proj.appspot.com/o/broken.png?alt=media&token=b89f711d-c90d-46ed-84c8-123456789";

CachedNetworkImage(
      imageUrl: uri,
      errorWidget: (context, url, error) => const Padding(
        padding: EdgeInsets.all(8.0),
        child: Icon(Icons.broken_image_outlined),
      ),
      imageBuilder: (context, imageProvider) {
        return Container(
          decoration: BoxDecoration(
            image: DecorationImage(
              image: CachedNetworkImageProvider(uri),
              fit: BoxFit.cover,
            ),
            color: Theme.of(context).cardTheme.color,
          ),
        );
      },
    );
  }

And it does as expected: It shows the Icons.broken_image_outlined for images that can't be loaded, like for example, the image that causes the exception above.

Expected behavior

I expect no exceptions to leak when the plugin seems to do what is expected.

Reproduction steps

Not sure, there's never any stack trace attached to the above exception, and as mentioned the actual behavior of the widget seems correct.

Configuration

Version: 3.2.1

Platform:

  • πŸ“± iOS (maybe)
  • πŸ€– Android

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions