Error in ApplicationShell postConstruct


I just upgraded from Theia 1.10 to 1.17 and I’m getting this error when Theia loads:

index.js:78 Error: @postConstruct error in class ApplicationShell: Cannot read property 'ready' of undefined
    at _postConstruct (instantiation.js:30)
    at Object.resolveInstance (instantiation.js:47)
    at resolver.js:72
    at (<anonymous>)
    at Object.resolveInstance (instantiation.js:40)
    at resolver.js:72
    at Object.resolve (resolver.js:96)
    at container.js:319
    at Container.__webpack_modules__.../node_modules/inversify/lib/container/container.js.Container._get (container.js:310)
    at Container.__webpack_modules__.../node_modules/inversify/lib/container/container.js.Container.get (container.js:230)

I checked and corePreferences is undefined although there is no injection error. Any idea how to fix that?

@Hanksha thank you for the discussion, do you have custom extensions included in your application?

CorePreferences was added as a constructor argument for ApplicationShell:

Hi @vince-fugnitto Yes my application is only made of extensions. Although I did not override/rebind the ApplicationShell, so I did not touch it.

I tried a workaround like this:

export class CustomApplicationShell extends ApplicationShell {
    protected init() {
        if (! {
            this.corePreferences.ready.then(() => {
            this.corePreferences.onPreferenceChanged(preference => {
                if (preference.preferenceName === 'window.menuBarVisibility') {

In that case it works and Theia loads correctly.

@Hanksha it is difficult to help or identify the proper solution without being able to look at the code for your specific extension(s). Are you extending TheiaDockPanel?

@vince-fugnitto No I’m not. The only issue really is that corePreferences is undefined the time that init is called but if I extend ApplicationShell and copy/paste the same init function body it works :thinking:. Maybe an issue with inversify somehow.

Did you upgrade your TypeScript compilation target from ES5 to ES2017?

@paul-marechal Yes I did, everything else works fine.

What does yarn why inversify return? I would recommend 5.1.1.

The result is:

=> Found "inversify@5.0.1"
info Reasons this module exists
   - "_project_#flux#@theia#core" depends on it
   - Hoisted from "_project_#flux#@theia#core#inversify"
info Disk size without dependencies: "996KB"
info Disk size with unique dependencies: "996KB"
info Disk size with transitive dependencies: "996KB"
info Number of shared dependencies: 0

It seems to be the version I get from @theia/core 1.17

@theia/core targets ^5.0.1 which matches 5.0.1 and up (until <6.0.0).

If upgrading your inversify version fixes the issue it might be worth updating the range in the framework.

Not sure what the command is to only upgrade one dependency, maybe yarn upgrade inversify?

@paul-marechal That command didn’t work, if I add inversify 5.1.1 to one of my package.json then I get build errors (I think because both versions are there and the latest might not be fully compatible with Theia 1.17)

yarn why inversify should tell you about any duplication.

Theia definitely works with inversify@5.1.1 as we’ve been using that version for 4 months now.

edit: I just tried master in case this is an error/regression we missed during the release and it works fine.

Yes both versions are there. I don’t know how to force it to use 5.1.1 for everything. It seems to always resolve to 5.0.1 from @theia/core.

You are fighting your lockfile. I would try one of 3 things:

  1. Get yarn to upgrade inversify (but seems like the command you tried didn’t work…)
  2. Delete the topmost declarations for inversify in your lockfile manually (erk but oh well)
  3. Use resolutions in your root package.json like "**/inversify": "5.1.1"?

@paul-marechal Ok I’ll try that tomorrow and post here if I managed to fix it.

I just forced yarn to pull inversify@5.0.1 on master to see if this would trigger the same error, and it did.

Upgrading to inversify@5.1.1 should fix your issue.

1 Like

I can confirm upgrading to Theia 1.17.1 fixes the issue. Thanks!

You may want to upgrade to Theia 1.17.2 now: we fixed a bug where the menu bar randomly disappeared.

1 Like