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

WebpackBundleLookupError: Cannot resolve bundle vendors. #2561

Closed
jnm opened this issue Jan 27, 2020 · 1 comment
Closed

WebpackBundleLookupError: Cannot resolve bundle vendors. #2561

jnm opened this issue Jan 27, 2020 · 1 comment
Assignees
Labels

Comments

@jnm
Copy link
Member

jnm commented Jan 27, 2020

When deploying the latest two-databases to kf.beta.kbtdev.org:
https://sentry.kbtdev.org/kobo/kpi-backend-dev/issues/307008/

WebpackBundleLookupError: Cannot resolve bundle vendors.
  File "django/core/handlers/exception.py", line 34, in inner
    response = get_response(request)
  File "django/core/handlers/base.py", line 145, in _get_response
    response = self.process_exception_by_middleware(e, request)
  File "django/core/handlers/base.py", line 143, in _get_response
    response = response.render()
  File "django/template/response.py", line 106, in render
    self.content = self.rendered_content
  File "django/template/response.py", line 83, in rendered_content
    content = template.render(context, self._request)
  File "django/template/backends/django.py", line 61, in render
    return self.template.render(context)
  File "django/template/base.py", line 171, in render
    return self._render(context)
  File "django/template/base.py", line 163, in _render
    return self.nodelist.render(context)
  File "django/template/base.py", line 937, in render
    bit = node.render_annotated(context)
  File "django/template/base.py", line 904, in render_annotated
    return self.render(context)
  File "django/template/loader_tags.py", line 150, in render
    return compiled_parent._render(context)
  File "django/template/base.py", line 163, in _render
    return self.nodelist.render(context)
  File "django/template/base.py", line 937, in render
    bit = node.render_annotated(context)
  File "django/template/base.py", line 904, in render_annotated
    return self.render(context)
  File "django/template/loader_tags.py", line 150, in render
    return compiled_parent._render(context)
  File "django/template/base.py", line 163, in _render
    return self.nodelist.render(context)
  File "django/template/base.py", line 937, in render
    bit = node.render_annotated(context)
  File "django/template/base.py", line 904, in render_annotated
    return self.render(context)
  File "django/template/library.py", line 192, in render
    output = self.func(*resolved_args, **resolved_kwargs)
  File "webpack_loader/templatetags/webpack_loader.py", line 12, in render_bundle
    tags = utils.get_as_tags(bundle_name, extension=extension, config=config, attrs=attrs)
  File "webpack_loader/utils.py", line 45, in get_as_tags
    bundle = _get_bundle(bundle_name, extension, config)
  File "webpack_loader/utils.py", line 23, in _get_bundle
    bundle = get_loader(config).get_bundle(bundle_name)
  File "webpack_loader/loader.py", line 83, in get_bundle
    raise WebpackBundleLookupError('Cannot resolve bundle {0}.'.format(bundle_name))
@jnm jnm added the question label Jan 27, 2020
@jnm jnm self-assigned this Jan 27, 2020
@jnm
Copy link
Member Author

jnm commented Jan 30, 2020

It seems like this affects the kobo-install "staging" setup only. It would also affect "developer mode", but in that case, it's probably safe to assume the developer is using npm run watch or similar to keep the static files up to date.

The problem is that this script doesn't know about the new bundle:
https://github.com/kobotoolbox/kpi/blob/7b5a1e708d5436d6d6348eb9066ae223507fc4ef/docker/check_kpi_prefix_outdated.py

It just sees that the prefix matches and skips npm run build to save time:

kpi/docker/init.bash

Lines 40 to 42 in 7b5a1e7

if [[ ! -d "${KPI_SRC_DIR}/staticfiles" ]] || ! python "${KPI_SRC_DIR}/docker/check_kpi_prefix_outdated.py"; then
echo 'Building static files from live code.'
(cd "${KPI_SRC_DIR}" && npm run build && python manage.py collectstatic --noinput)

npm run build inside the Dockerfile is doing its job, but the static files it builds are shadowed when staging mode mounts the source directory inside the containers:

/home/ubuntu/developer-environments/automated-build-workspaces/master/kpi:/srv/src/kpi:rw

In the case of our staging server, /home/ubuntu/developer-environments/automated-build-workspaces/master/kpi/jsapp/compiled not only didn't have vendors but was actually a dead symlink to /srv/build, which is a relic from an old version of the Dockerfile 1fcd297#diff-3254677a7917c6c01f55212f86c57fbfL11

Ultimately, I don't think this will affect anyone except us. I trashed those old symlinks and it's working. We'll see what happens if i change the frontend code and rebuild—will it:

  1. npm run build my new code during the Docker build process
  2. shadow the result of that build by mounting the source directory, which contains outdated compiled JS, inside the container
  3. see that the prefix still matches the compiled JS and do nothing?

This kind of gets back to kobotoolbox/kobo-install#8.

@jnm jnm closed this as completed Jan 30, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant