Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

KeyError: 'status' when trying to render_bundle #312

Closed
bunnymatic opened this issue Jan 19, 2022 · 2 comments
Closed

KeyError: 'status' when trying to render_bundle #312

bunnymatic opened this issue Jan 19, 2022 · 2 comments

Comments

@bunnymatic
Copy link

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

@joaopslins
Copy link
Contributor

joaopslins commented Jan 19, 2022

Hi @bunnymatic, it looks like you're using webpack-bundle-analyzer instead of webpack-bundle-tracker (https://github.com/django-webpack/webpack-bundle-tracker), which is the sibling library we use to generate the stats file. I think you got confused about which library to use. Would you mind trying the latter to check if it works?

@bunnymatic
Copy link
Author

Wow. That was dumb.

Thanks. That was indeed the problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants