Comments (4)
Hi, @pqseags. Thanks for writing in. I'm sorry you're having trouble with this.
Here are two suggestions:
-
The
run
method is a shorthand for creating a prediction and waiting for its result. It throws an error if the prediction fails. However, the longer formpredictions.create
method doesn'tthrow
, and instead populates itserror
property. So one option would be to migrate to that method instead. -
The issue could be that your
try
-catch
block isn't correctly catching promise rejections. If therun
method returns a promise that rejects, and that promise rejection isn't caught inside anasync
function, it could be causing yourcatch
block not to execute.
If the code you shared is part of anasync
function, it should catch the error properly. But if it's not, then you'll need to declare the enclosing function as async or handle the promise with.catch()
:replicate.run(model, { input }) .then(output => { console.log('after'); }) .catch(error => { console.log("catch"); });
from replicate-javascript.
Hmm I'm not familiar enough to say for sure. Definitely odd that I was seeing inconsistent behavior as well. Either way I'm happy with the predictions.create
solution - thanks for the help!
from replicate-javascript.
Thanks for the response @mattt. Your first suggestion worked well, and we wanted to migrate to use webhooks anyway so that's perfect.
Regarding the second suggestion however, the code is in an async
function, and I ran into the same issue with .catch()
. Perhaps the error is being thrown incorrectly in replicate's run
method? From my understanding it should be Promise.reject()
rather than throw new Error
from replicate-javascript.
@pqseags Thanks for the update. I'm glad to hear that you found a solution.
My understanding is that when an error is thrown inside an async function, it's automatically wrapped into a rejected Promise
.
from replicate-javascript.
Related Issues (20)
- Reading from "node:crypto" is not handled by plugins HOT 15
- Bun integration test is flakey, possibly due to bug in `stream` implementation HOT 3
- Error in : API request failed HOT 1
- npm test failing on Node 20
- Value error missing text 'input' HOT 1
- Cannot seem to run mistral as it doesn't have a version HOT 5
- `RangeError: Maximum call stack size exceeded` for image buffer input HOT 9
- Error 422 - Additional property signal not allowed. HOT 9
- TransformStream is not defined HOT 3
- Unexpected behavior: Error: Invalid version for official models HOT 2
- Document how to validate webhooks if your app is not using Request™ HOT 2
- Possible to get access to prompts and answers from other users HOT 3
- API responds 422 when input contains string[] HOT 4
- Replicate randomly fails with "Error: Prediction failed" HOT 4
- RangeError: Maximum call stack size exceeded when uploading image (in version 0.30.1) HOT 4
- alert message during build "require function is used in a way in which dependencies cannot be statically extracted" HOT 6
- replicate.files is undefined HOT 5
- ApiError: Request to https://api.replicate.com/v1/files failed with status 413 Request Entity Too Large HOT 1
- Use Bun macros to generate typed interfaces for models at bundle time
- Use Deno remote imports to provide packages for each Replicate model
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from replicate-javascript.