question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Bug] String injection with `instantiate: false` no longer works on ember 3.27.0

See original GitHub issue

🐞 Describe the Bug

Injecting a string via dependency injection raise an error.

🔬 Minimal Reproduction

Minimal reproduction on fresh app : https://github.com/romgere/test-ember-string-injection

  • Currently on ember 3.26 : working
  • Update to ember-source@3.27.0 : breaking

To sum-up Try to inject a string into a service with an initializer :

// initializer.js
export function initialize(application) {
  application.register('config:a-string', 'My great injected string', {
    instantiate: false,
  });

  application.inject(
    'service:test-injection',
    'injectedString',
    'config:a-string'
  );
}

export default {
  initialize,
};
// service.js
import Service from '@ember/service';

export default class TestInjectionService extends Service {
  injectedString = null; // injected by initializer
}

😕 Actual Behavior

When trying to use the service property got the following error :

Uncaught TypeError: Cannot create property 'Symbol(INIT_FACTORY)' on string 'My great injected string'

🤔 Expected Behavior

The property is setted with injected string.

🌍 Environment

  • Ember: 3.27.0
  • Node.js/npm: v12.20.2 (npm v6.14.11)
  • OS: ubuntu
  • Browser: chrome

➕ Additional Context

Related to what is done in https://github.com/yapplabs/ember-modal-dialog, see https://github.com/yapplabs/ember-modal-dialog/issues/320.

Issue Analytics

  • State:open
  • Created 2 years ago
  • Reactions:3
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
lifeartcommented, May 6, 2021

as workaround,

 application.register('config:a-string', { toString() => 'My great injected string' }, {
    instantiate: false,
  });

may work

0reactions
andsmedeiroscommented, Sep 23, 2021

Thanks @lifeart, this does the trick.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Deprecations Added in Ember 3.x
The deprecated copy function now handles array copies directly, no longer delegating to NativeArray.copy . With this deprecation, NativeArray no longer ...
Read more >
Ember Changelog - GitHub
#19868 [BUGFIX] Fix a bug with the implicit injections deprecation that meant injecting a store to avoid the deprecation did not work.
Read more >
Injecting dependencies into an Ember model - Stack Overflow
I'm attempting to inject dependencies into my Ember models. https://github.com/emberjs/ember.js/issues/3670, states that this is disabled.
Read more >
@ember-data/debug | Yarn - Package Manager
Ember Data Changelog. 4.9.1 (2022-12-03). :bug: Bug Fix. tracking. #8314 fix: tracking package should not declare exports while v1 (@runspired) ...
Read more >
Application Concerns: Dependency Injection - Ember.js
By default, Ember will attempt to instantiate a registered factory when it is looked up. When registering an already instantiated object instead of...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found