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

bug: Starting server with yarn start errors with RepositoryNotFoundError #49

Closed
1 task done
lukewhrit opened this issue Jun 4, 2020 · 14 comments
Closed
1 task done
Assignees
Labels
💥 bug Something isn't working ⚠️ urgent Needs to be fixed soon

Comments

@lukewhrit
Copy link
Member

lukewhrit commented Jun 4, 2020

REMEMBER: Issues related to the cli client or frontend will not be tolerated in this repo. This is for server/backend issues only. Check the box below if you understand:

  • I understand.

Describe the bug

Starting server with yarn start errors with RepositoryNotFoundError: No repository for "undefined" was found. Looks like this entity is not registered in current "default" connection?.

Stack trace:

▶ yarn start
yarn run v1.22.4
$ yarn build && node dist/server.js
$ ./node_modules/.bin/swc src/ -s -d dist/
Successfully compiled 8 files with swc.
Spacebin started on 0.0.0.0:7777
(node:55636) UnhandledPromiseRejectionWarning: RepositoryNotFoundError: No repository for "undefined" was found. Looks like this entity is not registered in current "default" connection?
    at new RepositoryNotFoundError (/home/luke/code/git/spacebin/spacebin/node_modules/typeorm/error/RepositoryNotFoundError.js:11:28)
    at EntityManager.getRepository (/home/luke/code/git/spacebin/spacebin/node_modules/typeorm/entity-manager/EntityManager.js:670:19)
    at Connection.getRepository (/home/luke/code/git/spacebin/spacebin/node_modules/typeorm/connection/Connection.js:344:29)
    at /home/luke/code/git/spacebin/spacebin/dist/routes/document.route.js:1:1304
    at Generator.next (<anonymous>)
    at asyncGeneratorStep (/home/luke/code/git/spacebin/spacebin/dist/routes/document.route.js:1:530)
    at _next (/home/luke/code/git/spacebin/spacebin/dist/routes/document.route.js:1:845)
(node:55636) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:55636) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

To Reproduce

  1. yarn start
  2. See error.

Expected behavior

The server should've ran with no issues.

Screenshots

N/A

Additional context

  • This issue does not happen when running with ts-node (yarn watch). I'm unsure as to why.
  • I'm using node version 12.
@lukewhrit lukewhrit added the 💥 bug Something isn't working label Jun 4, 2020
@lukewhrit lukewhrit changed the title bug: Starting server with yarn start errors RepositoryNotFoundError bug: Starting server with yarn start errors with RepositoryNotFoundError Jun 4, 2020
@lukewhrit lukewhrit self-assigned this Jun 4, 2020
@jackdorland
Copy link
Contributor

Screen Shot 2020-06-04 at 6 55 15 PM
I take it back; I can repro..

@lukewhrit
Copy link
Member Author

lukewhrit commented Jun 4, 2020

I think I have a quick and dirty patch I can make. Just making (and possibly keeping open) a connection when the server starts will probably work.

Update: This did not work. After some investigating it may be an issue with how we load our entities.

@jackdorland
Copy link
Contributor

I'll be assigning Urgent to this issue; Please link a PR you think would fix it when it's ready.

@jackdorland jackdorland added the ⚠️ urgent Needs to be fixed soon label Jun 4, 2020
@lukewhrit
Copy link
Member Author

I'll be assigning Urgent to this issue; Please link a PR you think would fix it when it's ready.

Working on it.

@lukewhrit
Copy link
Member Author

Our built document entity has no content.

image

So, this must be an issue with swc's building decorators.

@jackdorland
Copy link
Contributor

Sounds good; What's the TS code look like? Are you sure you handled the asnyc/await properly?

@lukewhrit
Copy link
Member Author

lukewhrit commented Jun 5, 2020

Sounds good; What's the TS code look like? Are you sure you handled the asnyc/await properly?

import { Entity, Column, PrimaryColumn } from 'typeorm'
import config from '../config'

@Entity()
export class Document {
  @PrimaryColumn({
    // Enforce key length
    length: config.options.keyLength
  })
  id: string

  @Column()
  content: string
}

It has the class decorator but doesn't seem to have any field decorators

@lukewhrit
Copy link
Member Author

I think that in order to fix this we need to start using a different TS compiler.

I suggest rollup with the rollup typescript plugin.

@jackdorland
Copy link
Contributor

Rest in peace swc 🙏 ⚰️ :suspect:

What else is there? I guess rollup could be fine, too.
Make an issue about it in the swc GitHub; I hope that's fixed soon enough.

@jackdorland jackdorland pinned this issue Jun 5, 2020
@lukewhrit
Copy link
Member Author

lukewhrit commented Jun 5, 2020

Rest in peace swc :suspect:

What else is there? I guess rollup could be fine, too.
Actually, we could possibly use esbuild.

Update: After some research, esbuild is not a viable option. It has no support for decorators. See more here.

Make an issue about it in the swc GitHub; I hope that's fixed soon enough.

I'll make an issue when this is confirmed to be an issue with swc and not something else.

Update: This was confirmed to be an issue with swc, however someone else already created the issue.

@lukewhrit
Copy link
Member Author

lukewhrit commented Jun 5, 2020

Webpack, Rollup, and standard TSC are probably the best options.

TSC may be the best out of those. We haven't needed a more advanced build tool chain yet which is the main purpose of tools like Rollup.

@jackdorland
Copy link
Contributor

Sounds good to me; tsc usually the most stable imo

@lukewhrit
Copy link
Member Author

Sounds good to me; tsc usually the most stable imo

Alright. I'll put up a branch and move to tsc.

@lukewhrit lukewhrit added this to In progress in Spacebin TODO Jun 5, 2020
@lukewhrit
Copy link
Member Author

Sounds good to me; tsc usually the most stable imo

Alright. I'll put up a branch and move to tsc.

Done. See the lukewhrit-tsc branch.

@lukewhrit lukewhrit moved this from In progress to Done (Ready for next release) in Spacebin TODO Jun 5, 2020
@lukewhrit lukewhrit unpinned this issue Jun 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
💥 bug Something isn't working ⚠️ urgent Needs to be fixed soon
Projects
No open projects
Spacebin TODO
  
Completed
Development

No branches or pull requests

2 participants