error loading main.js on my new project no matter what

Not favoritedFavorited Favorited 0 favourites
  • 12 posts
From the Asset Store
Custom Loading Icons to Enhance Your Loading Screens
  • I've just created a new project and realized construct has a couple new options when right clicking the scripts folder, related to typescript. I suspect I'm misunderstanding them, because my main script will fail no matter what. I'm trying to use typescript, edited thru vs code (as I've been doing for a while). I'm getting this on the console:

    Failed to load resource: net::ERR_HTTP2_PROTOCOL_ERROR

    sw.js:617 [SW-Preview] Up to date

    bootPreview.js:105 Registered service worker on preview.construct.net

    domSide.js:1 Error loading project main script: Error: main script did not run to completion

    at r._InitDOM (domSide.js:1:12370)

    at async r._Init (domSide.js:1:8594)

    _InitDOM domSide.js:1

    webgpuRenderer.js:1 The powerPreference option is currently ignored when calling requestAdapter() on Windows. See crbug.com/369219127

    Tagged:

  • Failed to load resource: net::ERR_HTTP2_PROTOCOL_ERROR

    This looks like some kind of networking error occurred. Try clearing your browser cache and giving it another go.

  • Thank you for the response Ashley, but it did not work.

    To be clear, I am able to preview other projects.

  • If it's just one project with the error, then it's probably a mistake in your code (e.g. if an exception is thrown at the top level of the main script, that error will come up). The quickest way to get help with that would be to share your project, or at least the code that causes the problem.

  • My project is really minimal since I've just created it. Here it goes:

    drive.google.com/file/d/1b-xocb2KfHf4UnULT8djQ7MeogYRCdWQ/view

    I'm pretty sure the code is alright, and I'm so sorry for wasting your time if the problem is as simple as such an oversight from me.

  • OK, this does actually look like a bug in Construct, but the main issue seems to be it's a strange project configuration. Usually if you want to code with TypeScript inside Construct, you'd have just .ts files. But you have .js files in the project too. Normally you'd use one of two workflows for TypeScript:

    1. Have just .ts files in your project, and let Construct automatically compile those to JavaScript
    2. Have just .js files in your project, and edit .ts files with an external editor like VS Code that compiles to the .js files used in the project

    So how come you have both .ts and .js files? Are you expecting Construct to compile .ts files and overwrite the .js files? In that case there's no point having .js files in the project itself, hence the first workflow.

    I'll see if the bug can be fixed for the next release cycle (we're close to a stable release at the moment and this doesn't seem like an essential fix) - in the mean time you can work around this by just deleting the .js files from the project.

  • Thanks for the reply again Ashley. Yes, I was expecting construct to overwrite the js files and I had no idea I could just delete them from the project and have it compile them somewhere hidden. I was messing with the new built-in editor and trying to edit ts from construct, but I mainly use vs code and now can't figure out how to configure it to work with vs code handling the ts again.

  • So, I've created a new project. It won't give me errors anymore but now runOnStartup() just isn't called... What?

    Edit: It all appears to still come down to that "Failed to load resource: net::ERR_HTTP2_PROTOCOL_ERROR".

  • It's difficult to help unless you share a copy of your project. I could never have possibly guessed the previous problem until you shared your project file.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • It is exactly the same error, but here you go: drive.google.com/file/d/1b-xocb2KfHf4UnULT8djQ7MeogYRCdWQ/view

    Do you also get the same error on your end? It seems like something related to my browser to me, idk.

  • The project has no main script set. You need to select main.js in the Project Bar, and in the Properties Bar set its purpose to 'Main script'. Otherwise Construct won't load any script.

  • Oh, so now they work just like event sheets do, which I didn't realize. So sorry for that and thank you so much as always.

    Edit: Now that I think of it, I think this was because of the way I replaced the main script when creating the new project. After setting the main script, we are back to the same error that started this thread. So no, the "weird typescript setup" wasn't the problem.

Jump to:
Active Users
There are 0 visitors browsing this topic (0 users and 0 guests)