Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

originalFunc is not a function #2

Open
brams-dev opened this issue Jun 29, 2022 · 2 comments
Open

originalFunc is not a function #2

brams-dev opened this issue Jun 29, 2022 · 2 comments

Comments

@brams-dev
Copy link

I'm using mock_file@v1.0.1 with sqlite@v3.4.0 on Deno Deploy with the fresh framework. I get this error:

An error occured during route handling or page rendering. TypeError: originalFunc is not a function
    at Object.openSync (https://deno.land/x/mock_file@v1.0.1/src/polyfill.ts:120:20)
    at js_open (https://deno.land/x/sqlite@v3.4.0/build/vfs.js:29:24)
    at denoOpen (wasm://wasm/002a4c4a:1:3005)
    at sqlite3PagerSharedLock (wasm://wasm/002a4c4a:1:30327)
    at sqlite3BtreeBeginTrans (wasm://wasm/002a4c4a:1:24816)
    at sqlite3InitOne (wasm://wasm/002a4c4a:1:157318)
    at sqlite3Init (wasm://wasm/002a4c4a:1:156554)
    at sqlite3ReadSchema (wasm://wasm/002a4c4a:1:100815)
    at sqlite3LocateTable (wasm://wasm/002a4c4a:1:98255)
    at sqlite3LocateTableItem (wasm://wasm/002a4c4a:1:245062)

Running it locally works fine.

@ayame113
Copy link
Owner

ayame113 commented Jun 30, 2022

First of all, thank you for your interest in this module!👍

I think I've also encountered this error. The solution at that time was:

The sqlite module will try to write to the journal file. Therefore, it is necessary to prepare a writable temporary file using prepareVirtualFile.

import {
  prepareLocalFile,
  prepareVirtualFile,
} from "https://deno.land/x/mock_file@$VERSION/mod.ts";

const dbFileName = "./db.sqlite";
await prepareLocalFile(dbFileName);
prepareVirtualFile(`${dbFileName}-journal`); // <- This line is needed!

We apologize if you have already done this. In that case, could you please provide the code that can reproduce the error?

I will work to improve this error message. (For example like Error: cannot open ${fileName} because...)

@brams-dev
Copy link
Author

This fixed the issue for me, thank you!
Thank you for making this module!

@ayame113 ayame113 pinned this issue Jun 30, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants