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

Development server must be restarted after each configuration change #146

Closed
jelhan opened this issue Jul 15, 2020 · 2 comments · Fixed by #158
Closed

Development server must be restarted after each configuration change #146

jelhan opened this issue Jul 15, 2020 · 2 comments · Fixed by #158
Labels
Milestone

Comments

@jelhan
Copy link
Collaborator

jelhan commented Jul 15, 2020

Changes to the configuration in config/ember-cli-content-security-policy.js are not reflected by a running development server instance even so they trigger a rebuild. A restart of the development server is required. This should be either documented or resolved.

@jelhan jelhan added the bug label Jul 15, 2020
@rwjblue
Copy link
Owner

rwjblue commented Jul 15, 2020

What would we need to do to handle this without a restart? Obviously part of the issue is with require caching, but do all of our systems re-run for each request (if we bust that cache)?

@jelhan
Copy link
Collaborator Author

jelhan commented Jul 15, 2020

I debugged a little bit:

  • As described above changing config/content-security-policy.js triggers a reload. But both the CSP header as well as CSP meta tag does not reflect the change.
  • config and contentFor hooks are run when config/content-security-policy.js changes.
  • serverMiddleware hook does not run when config/content-security-policy.js. But the express middleware registered in that hook runs on each request.
  • The addon configuration is calculated ones and cached. There isn't any logic that invalidates the cache.

I guess there are two soulutions to this issue:

  1. Not caching the calculated CSP and other configuration.
  2. Invalidating that cache when config/content-security-policy.js changes.

I guess it's a decision between two tradeoffs: The time needed to calculate the CSP and other derived configuration on each reload and additional work needed for caching. I think we can ignore memory overhead. But the time needed to derive a caching key and comparing it to the key used for cached configuration should be significantly smaller than the time needed to calculate configuration. To be honest I'm not sure if caching pays off at the end of the day at all for this scenario.

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

Successfully merging a pull request may close this issue.

2 participants