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

Update 1.5.1 to 1.5.2 cause empty __meteor_runtime_config__ #9149

Closed
stefanocudini opened this issue Sep 28, 2017 · 10 comments
Closed

Update 1.5.1 to 1.5.2 cause empty __meteor_runtime_config__ #9149

stefanocudini opened this issue Sep 28, 2017 · 10 comments
Assignees

Comments

@stefanocudini
Copy link

stefanocudini commented Sep 28, 2017

After upgrading to Meteor 1.5.2, I am experiencing a strange bug! meteor_runtime_config is empty!

the html page http://localhost:3000/ contains:

<script type="text/javascript">
__meteor_runtime_config__ = JSON.parse(decodeURIComponent(<%= conf %>))
</script>
  <script type="text/javascript" src="<%- src %>"></script>
  <script type="text/javascript" src="<%- src %>"></script>
...

later I tried with: meteor reset
and also a downgrade: meteor update --release 1.5.1
but the issue persist!!

I can not understand how I can investigate the problem! 😦
(nodejs --version is v8.6.0)

many thanks

@stefanocudini stefanocudini changed the title Meteor 1.5.1 -> Meteor 1.5.2 cause empty __meteor_runtime_config__ Update 1.5.1 to 1.5.2 cause empty __meteor_runtime_config__ Sep 28, 2017
@stefanocudini
Copy link
Author

stefanocudini commented Sep 28, 2017

find a "solution"... I can suppose this is caused by the package boilerplate-generator but this is included (version 1.2.0) in my application

@stefanocudini
Copy link
Author

stefanocudini commented Sep 28, 2017

the problem only in Meteor 1.5.2(on 1.5.1 all work) is a custom configuration of a standard function of underscore _.template

I reconfigured _.template function has following

_.templateSettings = {
	interpolate: /\{(.+?)\}/g
};

this settings block the work of boilerplate-generator

@RobertLowe
Copy link
Contributor

I can confirm this is a legitimate issue as well, we should not be mixing underscores in user-land and meteor-land...

Thanks for posting this @stefanocudini

Pinging @benjamn @hwillson @glasser

@glasser
Copy link
Contributor

glasser commented Oct 19, 2017

This is probably related to Steven's project this summer.

@RobertLowe
Copy link
Contributor

RobertLowe commented Oct 19, 2017

@glasser This just happen to me.

  1. Updated active project from 1.5.2.1 to 1.5.2.2

  2. App would start but content would not be properly interpolated.

  3. Found offending:

    _.templateSettings = {
    	interpolate: /\{(.+?)\}/g
    };
    
  4. Removed offending code, issue was resolved.

So the _ used by meteor and in user land are mixing. Very leaky. 🤔

@hwillson
Copy link
Contributor

Thanks @RobertLowe - re-opening. I haven't had a chance to look into this yet, but I'll plan on digging in shortly.

@hwillson hwillson reopened this Oct 20, 2017
@hwillson hwillson self-assigned this Oct 20, 2017
@stefanocudini
Copy link
Author

stefanocudini commented Oct 20, 2017

Thanks @RobertLowe you too!
I solved the problem simply editing my code.. and removing my customization of underscore in templateSettings but I don't sure this is the best way to fix the problem..
I did this because I needed the new Meteor version and could not wait to wait for other official solution...

I've got to study the code that creates the problem, but I think it's not easy to solve at this time, we need to isolate the context with which we use underscore within Meteor over the context in which the user works and I haven't idea how to do it .. goes beyond my knowledge of Meteor.

I would appreciate if there was a solution that allows meteor users to modify their template system ^_^

@hwillson @RobertLowe
underscore template() method used by boilerplate-generator is here:
https://github.com/meteor/meteor/blob/devel/packages/boilerplate-generator/template-web.browser.js#L43

Obviously as in my case, if the user decides to change the underscore templateSetting configuration at a global level then also boilerplate-generator breaks! :-(

@RobertLowe
Copy link
Contributor

Thanks @hwillson ! 👍

@stefanocudini thanks for posting on the forums and an issue here, it sure saved me a bunch of time! Yes, I think ideally they would be isolated instances. _.template(templateString, [settings]) allows for interpolate option to be passed in if you like (ex: _.template("<div>{{thing}}</div>", {interpolate: /\{\{(.+?)\}\}/g} )({thing: 'awesome'});

@stefanocudini
Copy link
Author

@RobertLowe I can tell you exactly... about 3 days of research! ^_^

hwillson added a commit to hwillson/meteor that referenced this issue Oct 20, 2017
When `underscore`'s default `_.template` settings are overridden
using `_.templateSettings` in an application, this can adversely
affect the `_.template` calls used by the `boilerplate-generator`
to render an application's initial HTML template. These changes
make sure the `boilerplate-generator` is overridding any
defined `_.templateSettings` with its own verified to work
settings.

Fixes meteor#9149.
@hwillson
Copy link
Contributor

I've submitted PR #9250 to help address this. The fact that this could happen in the first place isn't great (and as you mentioned @RobertLowe is leaky), but this quick fix should help for now.

abernix pushed a commit that referenced this issue Nov 8, 2017
* Handle overridden _.template settings in boilerplate-generator

When `underscore`'s default `_.template` settings are overridden
using `_.templateSettings` in an application, this can adversely
affect the `_.template` calls used by the `boilerplate-generator`
to render an application's initial HTML template. These changes
make sure the `boilerplate-generator` is overridding any
defined `_.templateSettings` with its own verified to work
settings.

Fixes #9149.

* Add comment explaining additional _.template config override

* Handle overridden _.templateSettings with the cordova boilerplate

* Remove underscore use wherever possible

* Change incorrect implementation of an "empty" manifest.

This test was trying to imply an empty manifest by using an empty
associative array (hash), whereas a manifest is only ever an array
of hashes (as per the bundler code).  Therefore, an empty manifest
should be an array with no items.

This is to fix the failure seen in https://travis-ci.org/meteor/meteor/builds/291857783?utm_source=github_status&utm_medium=notification
because of @hwillson's changes in 9aee811.

Refs: #9250.

* Make underscore replacement code more defensive

`_.map` handles a falsy input value, whereas `Array.prototype.map`
(obivously) does not. While not likely common practice, it's
possible falsy values are being passed into the boilerplate
generator, for elements like `js`, `css`, etc. These changes
replicate `_.map`'s handling of incoming falsy values by
converting them to an empty array.
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

4 participants