Skip to content

KeyError: 'status' when trying to render_bundle #312

Closed
@bunnymatic

Description

@bunnymatic

On a fresh Django project, I'm running into issues where it appears my webpack bundle is missing the status key and django-webpack-loader is failing to render_bundle

Here is the trimmed traceback.

Internal Server Error: /
Traceback (most recent call last):
  File "/Users/jon/Library/Caches/pypoetry/virtualenvs/django-react-19wCKYUK-py3.9/lib/python3.9/site-packages/django/core/handlers/exception.py", line 47, in inner
    response = get_response(request)
  File "/Users/jon/Library/Caches/pypoetry/virtualenvs/django-react-19wCKYUK-py3.9/lib/python3.9/site-packages/django/core/handlers/base.py", line 181, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "/Users/jon/projects/django-react/main/views.py", line 8, in index
    return render(request, "things/index.html", ctx)
...
  File "/Users/jon/Library/Caches/pypoetry/virtualenvs/django-react-19wCKYUK-py3.9/lib/python3.9/site-packages/webpack_loader/templatetags/webpack_loader.py", line 20, in render_bundle
    tags = utils.get_as_tags(
  File "/Users/jon/Library/Caches/pypoetry/virtualenvs/django-react-19wCKYUK-py3.9/lib/python3.9/site-packages/webpack_loader/utils.py", line 61, in get_as_tags
    bundle = _get_bundle(bundle_name, extension, config)
  File "/Users/jon/Library/Caches/pypoetry/virtualenvs/django-react-19wCKYUK-py3.9/lib/python3.9/site-packages/webpack_loader/utils.py", line 39, in _get_bundle
    bundle = get_loader(config).get_bundle(bundle_name)
  File "/Users/jon/Library/Caches/pypoetry/virtualenvs/django-react-19wCKYUK-py3.9/lib/python3.9/site-packages/webpack_loader/loader.py", line 80, in get_bundle
    while assets['status'] == 'compile' and not timed_out:
KeyError: 'status'

If I look at my stats.json file, there is no key status. The react side was started with CRA and using webpack-bundle-analyzer to generate the stats.json file with this configuration

const BundleAnalyzerPlugin =
  require("webpack-bundle-analyzer").BundleAnalyzerPlugin;

module.exports = function () {
  return {
    webpack: {
      plugins: [new BundleAnalyzerPlugin({ analyzerMode: "json", generateStatsFile: true })],
    },
  };
};

I can't find any options on this plugin to add the status column. I wonder if this is a standard key or if this plugin might be a bit more flexible if it didn't require that key to be there.

# pyproject.toml - the related bits
python = "^3.9"
Django = "^4.0.1"
django-webpack-loader = "^1.4.1"

Any ideas?

Here's a screenshot of the folded stats.json - I can add the full contents if that would help, it seemed like maybe overkill. But you can see that there is no top level status key.

image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions