Uncaught Error: FFI dependency not provided: url
GuillaumeDesforges opened this issue · 3 comments
I hit an unexpected error.
module Main where
import Prelude
import Control.Monad.Free (Free)
import Control.Monad.Reader (runReaderT)
import Effect (Effect)
import Effect.Class (liftEffect)
import Main (app)
import Node.Express.Test.Mock (assertStatusCode, createMockApp, sendRequest, setupMockApp)
import Node.Express.Types (Method(..))
import Test.Unit (TestF, describe, it)
import Test.Unit.Main (runTest)
import Node.Express.App (App, get, listenHttp)
import Node.Express.Response (sendJson)
main ∷ Effect Unit
main = runTest testServer
testServer ∷ Free TestF Unit
testServer =
describe "server" do
it "responds with HTTP status 200" do
mockApp <- liftEffect $ createMockApp
(flip runReaderT) mockApp do
setupMockApp app
sendRequest GET "http://example.com/" identity (assertStatusCode 200)
app :: App
app =
let
handler = sendJson { message: "ok" }
in
do
get "/*" handler
get "/" handler
I get no result and the console gives me:
VM3687:3 Uncaught Error: FFI dependency not provided: url
at eval (eval at load (VM1581 frame.js:25:7), <anonymous>:3:7)
at load (VM1581 frame.js:25:66)
at require (VM1581 frame.js:22:16)
at eval (Node.Express.Test.Mock/foreign.js:5:11)
at load (VM1581 frame.js:25:66)
at require (VM1581 frame.js:22:16)
at eval (Node.Express.Test.Mock/index.js:4:16)
at load (VM1581 frame.js:25:66)
at require (VM1581 frame.js:22:16)
at eval (eval at load (VM1581 frame.js:25:7), <anonymous>:12:30)
We don't provide FFI shims for all libraries in the PureScript package sets; you can't execute Node libraries on Try PureScript, but the compiler will still happily typecheck it for you.
Thanks for the quick reply.
Maybe it'd be helpful to add it to the doc? Or try to provide a meaningful error message to users when that happens?
It's possible to catch this error and bubble it up to the Halogen application, displaying a message to the user directly. However, since the core team is currently working on a new compiler release and the new registry I think it's unlikely anyone gets to it in the near term. That said, I'd certainly accept pull requests that help surface this error or a warning to the user!