Skip to content

fix(vue-renderer): read target from class instead of serverContext #7752

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

Merged
merged 2 commits into from
Jul 22, 2020
Merged

fix(vue-renderer): read target from class instead of serverContext #7752

merged 2 commits into from
Jul 22, 2020

Conversation

timrchavez
Copy link

@timrchavez timrchavez commented Jul 21, 2020

The renderRoute method assumes that this.serverContext.nuxt.options is a valid path, but that does not seem like a good assumption AFAICT. We could defensively check for its existence, but I think the correct thing to do here, is to use this.options instead.

I'm not sure how this was working before, but I hit this particular problem while trying to use nuxt-lambda which creates a minimal serverContext that doesn't include serverContext.nuxt.options. See: https://github.com/pimlie/nuxt-lambda/blob/master/src/renderer.js#L8-L21 -- I freely admit that the bug could lie there. I tried to find some authoratative documentation on serverContext but was unsuccessful.

Types of changes

  • Bug fix (a non-breaking change which fixes an issue)
  • New feature (a non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Description

Presently renderRouter assumes that serverContext has a nuxt.options.target field. This seems at odds with other areas within the code that need to access target and get it directly from serverContext.options. To remain consistent and remove (what I think is) an errant path, we should update the assignment of serverContext.target using this.options.target instead of this.serverContext.nuxt.options.target

Checklist:

I tried to run the tests locally but failed hard. Could not get jest to work.

  • My change requires a change to the documentation.
  • I have updated the documentation accordingly. (PR: #)
  • I have added tests to cover my changes (if not applicable, please state why)
  • All new and existing tests are passing.

Sorry, something went wrong.

The `renderRoute` method assumes that `this.serverContext.nuxt.options`
is a valid path, but that does not seem like a good assumption AFAICT.
We could defensively check for its existence, but I think the correct
thing to do here, is to use `this.options` instead.
@timrchavez
Copy link
Author

I had to amend the author on my commit as I am not representing my employer with this change :)

Rather than using `this.serverContext.options.target`, we should make
use of the shortcut `this.options.target`.
@codecov-commenter
Copy link

codecov-commenter commented Jul 21, 2020

Codecov Report

Merging #7752 into dev will not change coverage.
The diff coverage is 0.00%.

Impacted file tree graph

@@           Coverage Diff           @@
##              dev    #7752   +/-   ##
=======================================
  Coverage   68.83%   68.83%           
=======================================
  Files          90       90           
  Lines        3821     3821           
  Branches     1034     1034           
=======================================
  Hits         2630     2630           
  Misses        968      968           
  Partials      223      223           
Flag Coverage Δ
#unittests 68.83% <0.00%> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
packages/vue-renderer/src/renderer.js 0.00% <0.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 7aa46f5...e389984. Read the comment docs.

@pi0
Copy link
Member

pi0 commented Jul 22, 2020

Hi, @timrchavez thanks for the PR and well-detailed explanations ❤️ It totally makes sense to merge this PR as both a fix and simplification refactor. BTW I also opened pimlie/nuxt-lambda#6 to fix the root cause.

@pi0 pi0 changed the title fix(vue-renderer): Use correct options path for target fix(vue-renderer): read target from class instead of serverContext Jul 22, 2020
@pi0 pi0 merged commit 2dc11a7 into nuxt:dev Jul 22, 2020
@pi0 pi0 mentioned this pull request Jul 22, 2020
@danielroe danielroe added the 2.x label Jan 18, 2023
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 this pull request may close these issues.

None yet

4 participants