thebaselab / codeapp

Building a full-fledged code editor for iPad
https://code.thebaselab.com
MIT License
2.9k stars 195 forks source link

Program interrupted. This could be caused by a memory limit or an error in your code. #818

Open JhunDigal opened 1 year ago

JhunDigal commented 1 year ago

Wasn’t able to use this app at all even with a very basic code!

MarZim81 commented 1 year ago

Same issue here, can‘t execute the „Creating a Node.js“ sample project.

bummoblizard commented 1 year ago

Let me know your device model and the iOS version for me to reproduce this problem.

MarZim81 commented 1 year ago

Sorry, totally forgot. Device: iPad Pro M2 Gen 6 iOS: 16.4.1

Same issue on my iPhone 13 with same iOS version.

hezhenwen502 commented 1 year ago

I also encountered this situation, and when using the npm i installation package, this error was reported. Device: iPad mini6 IOS:15.4.1

hezhenwen502 commented 1 year ago

让我知道您的设备型号和iOS版本,以便我重现此问题。

I also encountered this situation, and when using the npm i installation package, this error was reported. Device: iPad mini6 IOS:15.4.1

ppercent commented 1 year ago

same error here

zaychika commented 1 year ago

Same issue. I think it just comes down to a limitation of this app for error handling.

TLDR

This error is telling you there's a problem with your code, but the app cannot tell you what that problem is, or what file and line it's coming from in many cases.

Examples

Here's some examples in Node.js:

  1. Running nodemon app.js ERROR: Program interrupted. This could be caused by a memory limit or an error in your code Solution: Just use node app.js. Installing nodemon globally or as an app dependency doesn't work. You can't use nodemon with this platform. And it just doesn't know how to tell you that.

  2. Running node app.js with node package "Mongoose" ERROR: Program interrupted. This could be caused by a memory limit or an error in your code Solution: In my case, I was using deprecated syntax from an old version of mongoose. Just had to guess that was the problem and update per the docs. This error is explained in VSCode. But this app is missing something to show that output.

  3. Stopping a node app with ctrl-c ERROR: Program interrupted. This could be caused by a memory limit or an error in your code Solution: This is weird. There really is no problem. I'm just stopping the process like normal. But this app handles it like something went wrong. Kinda misleading.

Conclusion

Most desktop IDE/Editor solutions will tell you at least what file the problem is coming from. But in many cases, both the terminal and console output just can't offer any helpful hints. And speaking of the console (listed simply as 'problems' in the editor), well it has no badge or color to tell you one when an error has occurred.

I'm thrilled that something like this app even exists for iOS. Let alone one that is free and privacy respecting. We just need more detailed error handling to make this usable for daily work.

Device: iPad Pro 3rd Gen
OS: iPadOS 16.5
Code App Version: 1.4.4
RenzoAlessandro commented 1 year ago

Same error here… doesn't support creating new angular and react projects?

Envo commented 1 year ago

I tried it with a very-very simple react project and i got the same. Something is broken in the application.

Device: iPad Pro 3rd Gen OS: iPadOS 17.0 (Beta 4) Code App Version: 1.4.5

bummoblizard commented 1 year ago

I tried it with a very-very simple react project and i got the same. Something is broken in the application.

Device: iPad Pro 3rd Gen

OS: iPadOS 17.0 (Beta 4)

Code App Version: 1.4.5

Please use our React sample as a starting point: https://github.com/thebaselab/react-starter.

Envo commented 1 year ago

I tried it with a very-very simple react project and i got the same. Something is broken in the application.

Device: iPad Pro 3rd Gen

OS: iPadOS 17.0 (Beta 4) Code App Version: 1.4.5

Please use our React sample as a starting point: https://github.com/thebaselab/react-starter.

Yeah that's run, but what's the point if my own projects isn't...

bummoblizard commented 1 year ago

I tried it with a very-very simple react project and i got the same. Something is broken in the application.

Device: iPad Pro 3rd Gen

OS: iPadOS 17.0 (Beta 4)

Code App Version: 1.4.5

Please use our React sample as a starting point: https://github.com/thebaselab/react-starter.

Yeah that's run, but what's the point if my own projects isn't...

You can. It's just certain commands aren't available on Code App because of iOS's restriction. Usually, they try to spawn sub-processes.

You might send me a copy of your project at sh.chung@thebaselab.com and I will patch it for you.

Envo commented 1 year ago

I tried it with a very-very simple react project and i got the same. Something is broken in the application.

Device: iPad Pro 3rd Gen

OS: iPadOS 17.0 (Beta 4)

Code App Version: 1.4.5

Please use our React sample as a starting point: https://github.com/thebaselab/react-starter.

Yeah that's run, but what's the point if my own projects isn't...

You can. It's just certain commands aren't available on Code App because of iOS's restriction. Usually, they try to spawn sub-processes.

You might send me a copy of your project at sh.chung@thebaselab.com and I will patch it for you.

I take your answer as a kind joke. :) Of course i won't going to share these projects mostly because of security concerns...

Flmob commented 11 months ago

I tried it with a very-very simple react project and i got the same. Something is broken in the application.

Device: iPad Pro 3rd Gen

OS: iPadOS 17.0 (Beta 4)

Code App Version: 1.4.5

Please use our React sample as a starting point: https://github.com/thebaselab/react-starter.

Yeah that's run, but what's the point if my own projects isn't...

You can. It's just certain commands aren't available on Code App because of iOS's restriction. Usually, they try to spawn sub-processes.

You might send me a copy of your project at sh.chung@thebaselab.com and I will patch it for you.

Can you prrovide more info in wiki about starting node project in app? About app limitations, possible errors and how to start hevier that small epress eample apps. I believe this will help to prevent a lot of possible questions in the future

adamszigeti commented 11 months ago

I seem to have found a solution by wrapping my code in a try/catch block, and just console.logging/console.error-ing the error out (process.on("unhandledException", ...) and process.on("unhandledRejection", ...) did not work).

Though that alone won't work with async code. Instead, I suggest you wrap your whole program in a function, export it, and then use a new entry file like so:

// bootstrap.js
try {
  const { myWrappedProgram } = require("./myprogram.js")
  const result = myWrappedProgram()

  if (result && typeof result === "object" && "then" in result) {
    result.then(() => {}, console.error)
  }
}
catch (error) {
  console.error(error)
}

// myprogram.js
module.exports = { myWrappedProgram }

async function myWrappedProgram() {
  // ...
}

// to automatically start when the script is directly run via "node myprogram.js":
if (typeof require !== 'undefined' && require.main === module) {
    myWrappedProgram();
}

Now you start like so: node bootstrap.js.

I think it's actually really silly we have to do this, but until a fix is avaiable, this is better than nothing.

bummoblizard commented 8 months ago

Thanks all for the discussion. While it is not perfect, https://github.com/thebaselab/codeapp/commit/b0c6519b2340743b4afa7f8a968008c1c7eef39e should make uncaught errors reported properly. Additionally, node version is now updated to 18.

image