Giter Club home page Giter Club logo

opine_api's Issues

Trying out a POST request, "ReadableStream is locked" error

Hi,

Thanks for sharing this interesting and article — hope it’s ok if I ask a rather basic question.

I tried adding a flight to the db with a POST request, like this (from the browser, at localhost:3000):

fetch('http://localhost:3000/flight', {
  method: 'POST', 
  body: {
    departure: "Washington DC",
    destination: "Los Angeles",
    flightDuration: 5.5
  }
})
  .catch(e => console.log(e))

When I do that, the server crashes with this error:

opine_api/$ deno run --allow-net --allow-write --allow-read app.ts
https:\localhost: 3000

That’s startup, looks good — I can’t the Paris-Madrid flight at /flight.

But then I try running the fetch above, and this happens:

TypeError: ReadableStream is locked.
    at setUpReadableStreamDefaultReader (deno:ext/web/06_streams.js:3022:13)
    at new ReadableStreamDefaultReader (deno:ext/web/06_streams.js:4540:7)
    at acquireReadableStreamDefaultReader (deno:ext/web/06_streams.js:298:12)
    at ReadableStream.getReader (deno:ext/web/06_streams.js:4388:16)
    at WrappedRequest.get #body (https://deno.land/x/[email protected]/src/request.ts:310:46)
    at WrappedRequest.get body (https://deno.land/x/[email protected]/src/request.ts:315:36)
    at file:///Users/pat/Sites/Dev/deno/opine_api/routers/Routers.ts:50:37
    at Layer.handle [as handle_request] (https://deno.land/x/[email protected]/src/router/layer.ts:76:11)
    at next (https://deno.land/x/[email protected]/src/router/route.ts:104:13)
    at Route.dispatch (https://deno.land/x/[email protected]/src/router/route.ts:79:3)
error: Uncaught (in promise) SqliteError: table flights has no column named read
      throw new SqliteError(this._wasm);
            ^
    at DB.prepareQuery (https://deno.land/x/[email protected]/src/db.ts:190:13)
    at https://deno.land/x/[email protected]/lib/connectors/sqlite3-connector.ts:59:42
    at Array.map (<anonymous>)
    at SQLite3Connector.query (https://deno.land/x/[email protected]/lib/connectors/sqlite3-connector.ts:58:32)
    at Database.query (https://deno.land/x/[email protected]/lib/database.ts:240:47)
    at Function._runQuery (https://deno.land/x/[email protected]/lib/model.ts:228:42)
    at Function.create (https://deno.land/x/[email protected]/lib/model.ts:449:32)
    at file:///Users/pat/Sites/Dev/deno/opine_api/routers/Routers.ts:48:28
    at Layer.handle [as handle_request] (https://deno.land/x/[email protected]/src/router/layer.ts:76:11)
    at next (https://deno.land/x/[email protected]/src/router/route.ts:104:13)

Error when restarting the server "Uncaught PermissionDenied"

Once you have the server running and modify the database, and stop the server, it will show this:

Uncaught PermissionDenied: Acceso denegado. (os error 5), open './database.sqlite'
const rid = Deno.openSync(path, { read: true, write, create }).rid;
←[0m←[31m ^←[0m
at ←[0m←[1m←[3mObject.opSync←[0m (←[0m←[36mdeno:core/01_core.js←[0m:←[0m←[33m177←[0m:←[0m←[33m12←[0m)
at ←[0m←[1m←[3mObject.openSync←[0m (←[0m←[36mdeno:runtime/js/40_files.js←[0m:←[0m←[33m39←[0m:←[0m←[33m22←[0m)
at ←[0m←[1m←[3mjs_open←[0m (←[0m←[36mhttps://deno.land/x/[email protected]/build/vfs.js←[0m:←[0m←[33m27←[0m:←[0m←[33m24←[0m)
at ←[0m←[1m←[3mdenoOpen←[0m (←[0m←[36mwasm://wasm/0028f022←[0m:←[0m←[33m1←[0m:←[0m←[33m2960←[0m)
at ←[0m←[1m←[3msqlite3BtreeOpen←[0m (←[0m←[36mwasm://wasm/0028f022←[0m:←[0m←[33m1←[0m:←[0m←[33m148034←[0m)
at ←[0m←[1m←[3mopenDatabase←[0m (←[0m←[36mwasm://wasm/0028f022←[0m:←[0m←[33m1←[0m:←[0m←[33m144000←[0m)
at ←[0m←[1m←[3msqlite3_open_v2←[0m (←[0m←[36mwasm://wasm/0028f022←[0m:←[0m←[33m1←[0m:←[0m←[33m149501←[0m)
at ←[0m←[1m←[3mopen←[0m (←[0m←[36mwasm://wasm/0028f022←[0m:←[0m←[33m1←[0m:←[0m←[33m3771←[0m)
at ←[0m←[36mhttps://deno.land/x/[email protected]/src/db.ts←[0m:←[0m←[33m74←[0m:←[0m←[33m27←[0m
at ←[0m←[1m←[3msetStr←[0m (←[0m←[36mhttps://deno.land/x/[email protected]/src/wasm.ts←[0m:←[0m←[33m19←[0m:←[0m←[33m20←[0m)

I don't know why, but it "resolves" when the database.sqlite file is deleted.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.