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] Unhandled rejection when running script

See original GitHub issue
Overview of the issue

I run the script with compodoc -p src/tsconfig.app.json -s --theme material

then during execution, and after successfully parsing several files, I get

Unhandled Rejection at: Promise {
  <rejected> Error: Expected to find an initializer.
    at InvalidOperationError.BaseError [as constructor] ([project]\node_modules\ts-simple-ast\dist\errors\BaseError.js:7:28)
    at new InvalidOperationError ([project]\node_modules\ts-simple-ast\dist\errors\InvalidOperationError.js:8:28)
    at Object.throwIfNullOrUndefined ([project]\node_modules\ts-simple-ast\dist\errors\helpers.js:96:15)
    at EnumMember.InitializerGetExpressionableNode.class_1.getInitializerOrThrow ([project]\node_modules\ts-simple-ast\dist\compiler\base\initializer\InitializerGetExpressionableNode.js:25:27)
    at RouterParserUtil.cleanFileDynamics ([project]\node_modules\@compodoc\compodoc\dist\index-cli.js:1381:80)
    at AngularDependencies.getSourceFileDecorators ([project]\node_modules\@compodoc\compodoc\dist\index-cli.js:6306:45)
    at [project]\node_modules\@compodoc\compodoc\dist\index-cli.js:6118:31
    at Array.map (<anonymous>)
    at AngularDependencies.getDependencies ([project]\node_modules\@compodoc\compodoc\dist\index-cli.js:6106:21)
    at CliApplication.Application.getDependenciesData ([project]\node_modules\@compodoc\compodoc\dist\index-cli.js:7971:40) } reason: Error: Expected to find an initializer.
    at InvalidOperationError.BaseError [as constructor] ([project]\node_modules\ts-simple-ast\dist\errors\BaseError.js:7:28)
    at new InvalidOperationError ([project]\node_modules\ts-simple-ast\dist\errors\InvalidOperationError.js:8:28)
    at Object.throwIfNullOrUndefined ([project]\node_modules\ts-simple-ast\dist\errors\helpers.js:96:15)
    at EnumMember.InitializerGetExpressionableNode.class_1.getInitializerOrThrow ([project]\node_modules\ts-simple-ast\dist\compiler\base\initializer\InitializerGetExpressionableNode.js:25:27)
    at RouterParserUtil.cleanFileDynamics ([project]\node_modules\@compodoc\compodoc\dist\index-cli.js:1381:80)
    at AngularDependencies.getSourceFileDecorators ([project]\node_modules\@compodoc\compodoc\dist\index-cli.js:6306:45)
    at [project]\node_modules\@compodoc\compodoc\dist\index-cli.js:6118:31
    at Array.map (<anonymous>)
    at AngularDependencies.getDependencies ([project]\node_modules\@compodoc\compodoc\dist\index-cli.js:6106:21)
    at CliApplication.Application.getDependenciesData ([project]\node_modules\@compodoc\compodoc\dist\index-cli.js:7971:40)

Note: I have replaced full project path with [project].

Operating System, Node.js, npm, compodoc version(s)

OS: Windows 10, x64 (using PowerShell) Compodoc: 1.1.5 Node: 8.9.4 NPM: 5.6.0 Angular: 6.0.3

Angular configuration, a package.json file in the root folder

I’m not sure wether you need angular.json or package.json…?

Compodoc installed globally or locally ?

Installed compodoc locally to project with npm i --save-dev @compodoc/compodoc

If possible your terminal logs before the error

Last log before error:

parsing: [project]/src/app/groups/groups-routing.module.ts
Analysing routes definitions and clean them if necessary

This is the content of the file groups-routing.module.ts:

import { NgModule } from '@angular/core';
import { RouterModule, Routes } from '@angular/router';
import { GroupHandlerComponent } from './handlers/group-handler/group-handler.component';
import { ResolveGroup, GroupsService } from './services/groups.service';

const routes: Routes = [
	{
		path: '',
		component: GroupHandlerComponent,
		resolve: { content: GroupsService },
		data: { needs: ResolveGroup.multiple }
	},
	{
		path: ':groupid',
		component: GroupHandlerComponent,
		resolve: { content: GroupsService },
		data: { needs: ResolveGroup.single }
	}
];

@NgModule({
	imports: [RouterModule.forChild(routes)],
	exports: [RouterModule]
})
export class GroupsRoutingModule {}

Reproduce the error

Run compodoc -p src/tsconfig.app.json -s --theme material

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:2
  • Comments:7 (1 by maintainers)

github_iconTop GitHub Comments

4reactions
seydimomogueyecommented, Jan 9, 2019

Hi I had the same issue, i just removed the typing (export const routes: Routes = [] to export const routes = []) and it’s worked

2reactions
metakermitcommented, Apr 9, 2019

I’m experiencing this too. Would be nice if I didn’t have to un-type my routes in order to generate docs 🙂

Read more comments on GitHub >

github_iconTop Results From Across the Web

Window: unhandledrejection event - Web APIs | MDN
The unhandledrejection event is sent to the global scope of a script when a JavaScript Promise that has no rejection handler is rejected; ......
Read more >
javascript - Weird behavior with Promise throwing "Unhandled ...
This isn't an exception, it doesn't prevent a script from running normally. The way unhandled rejections are treated depends on Promise ...
Read more >
Handling those unhandled promise rejections with JS async ...
[UnhandledPromiseRejection: This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was ......
Read more >
Unhandled Promise Rejections in Node.js - The Code Barbarian
Calling reject() with a non-error is considered bad practice, but if you do, 'unhandledRejection' will get the argument you passed to reject() ...
Read more >
What does "failed due to an unhandled promise rejection ...
I have a synthetic script which mostly works, but fails consistently near the end with this error: Step 40: Click By.id("te_classbuilder") ...
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