Duplicate atom key "modalState" - next.js

What is this error and how to solve this ?
Expectation Violation: Duplicate atom key "modalState". This is a FATAL ERROR in
production. But it is safe to ignore this warning if it occurred because of
hot module replacement.
at expectationViolation (/home/prajan/Desktop/Nextjs/fuck/node_modules/recoil/cjs/index.js:558:19)
modalAtom.js
import { atom } from "recoil";
export const modalState = atom ({
key:"modalState",
default:false,
})

Related

Box node sdk on Deno throws "Not implemented: crypto.Sign" error

I want to use Box Node SDK on Deno (v1.30.3) . here is a simple example.
import BoxSDK from "npm:box-node-sdk#2.8.1";
import conf from "/path/to/config.json" assert {type: "json"};
const sdk = BoxSDK.getPreconfiguredInstance(conf);
const client = sdk.getAppAuthClient("enterprise");
client.users.get(client.CURRENT_USER_ID).then((me: any) => {
console.log(me); // should print user’s name
})
This is what I get.
error: Uncaught Error: Not implemented: crypto.Sign
throw new Error(message);
^
at notImplemented (https://deno.land/std#0.177.0/node/_utils.ts:23:9)
at new Sign (https://deno.land/std#0.177.0/node/internal/crypto/sig.ts:45:5)
at Object.createSign (https://deno.land/std#0.177.0/node/crypto.ts:268:10)
at Object.sign (file:///Users/hkobayashi/Library/Caches/deno/npm/registry.npmjs.org/jwa/1.4.1/index.js:151:25)
at Object.jwsSign \[as sign\] (file:///Users/hkobayashi/Library/Caches/deno/npm/registry.npmjs.org/jws/3.2.2/lib/sign-stream.js:32:24)
at Object.module.exports \[as sign\] (file:///Users/hkobayashi/Library/Caches/deno/npm/registry.npmjs.org/jsonwebtoken/8.5.1/sign.js:204:16)
at TokenManager.getTokensJWTGrant (file:///Users/hkobayashi/Library/Caches/deno/npm/registry.npmjs.org/box-node-sdk/2.8.1/lib/token-manager.js:286:48)
at AppAuthSession.\_refreshAppAuthAccessToken (file:///Users/hkobayashi/Library/Caches/deno/npm/registry.npmjs.org/box-node-sdk/2.8.1/lib/sessions/app-auth-session.js:79:18)
at AppAuthSession.getAccessToken (file:///Users/hkobayashi/Library/Caches/deno/npm/registry.npmjs.org/box-node-sdk/2.8.1/lib/sessions/app-auth-session.js:124:25)
at BoxClient.\_makeRequest (file:///Users/hkobayashi/Library/Caches/deno/npm/registry.npmjs.org/box-node-sdk/2.8.1/lib/box-client.js:300:18)
at BoxClient.get (file:///Users/hkobayashi/Library/Caches/deno/npm/registry.npmjs.org/box-node-sdk/2.8.1/lib/box-client.js:452:21)
at wrappedClientMethod (file:///Users/hkobayashi/Library/Caches/deno/npm/registry.npmjs.org/box-node-sdk/2.8.1/lib/box-client.js:589:30)
at Users.get (file:///Users/hkobayashi/Library/Caches/deno/npm/registry.npmjs.org/box-node-sdk/2.8.1/lib/managers/users.js:42:67)
at file:///Users/hkobayashi/dev/poc/poc24-deno/2023-02/box-hello.ts:8:14
Does this mean deno's crypto library hasn't yet fully implemented?
is there any workaround?

How to import GUN SEA with Deno Fresh?

The first attempt to import GUN from Fresh was to add the gun library from esm to import_map.json, where it correctly works in simple examples of using GUN.
{
"imports": {
...
"gun": "https://esm.sh/gun#0.2020.1237",
}
}
But the problem occurred when I wanted to import additionally gun/sea,
After importing import Sea from "gun/sea";.
I got this error:
error: Uncaught (in promise) Error: Dynamic require of "./lib/text-encoding" is not supported
On GitHub I read to import gun/lib/mobile before importing SEA when such a problem occurs.
But this brings an additional problem:
error: Uncaught (in promise) TypeError: Assignment to constant variable.
I checked the gun/lib/mobile file and it literally contains a few lines of global variables:
import Buffer from "buffer";
import { TextEncoder, TextDecoder } from "text-encoding";
global.Buffer = global.Buffer || Buffer.Buffer;
global.TextEncoder = TextEncoder;
global.TextDecoder = TextDecoder;
Is there any chance to make SEA work on Fresh?
Add following line inside imports in import_map.json file:
"#gun": "https://esm.sh/gun#0.2020.1237"
Then use this import statement to import GUN in any route/component:
import GUN from "#gun"
Usage (from GUN documentation):
const gun = GUN();
gun.get('mark').put({
name: "Mark",
email: "mark#gun.eco",
});
gun.get('mark').on((data, key) => {
console.log("realtime updates:", data);
});
setInterval(() => { gun.get('mark').get('live').put(Math.random()) }, 9);

Module not found: Error: Can't resolve './firebase' in 'C:

I'm getting this error in my vuejs webApp, hope some one tell me how to solve it:
./node_modules/babel-loader/lib!./node_modules/vue-loader/lib/selector.js?
type=script&index=0!./src/components/Envio.vue
Module not found: Error: Can't resolve './firebase' in
'C:\Users\#####\Desktop\#####\src\components'
# ./node_modules/babel-loader/lib!./node_modules/vue-loader/lib/selector.js?
type=script&index=0!./src/components/Envio.vue 17:0-32
# ./src/components/Envio.vue
# ./src/routes.js
# ./src/main.js
# multi (webpack)-dev-server/client?http://localhost:8080 webpack/hot/dev-
server ./src/main.js
this is the script in my vue file:
<script>
import { db } from './firebase'
export default {
data: {
mensaje: null,
... }
}
</script>
I assume you have installed firebase via a node package manager using npm command. If so, the following import statement should fix the problem.
import { db } from 'firebase'

When using Sqlite3 on Electron app , streams are undefined - Node's set-blocking module

We are working on a universal app, that must execute on mobile (ios, android), desktop (windows, mac, linux) adn in any browser.
For client database management, we want to use sqlite3 - for desktop- , in this case the app will be packaged using Electron (Atom shell) . The module bundler we are using is webpack, as the app is developed with Ionic 2 and Angular2.
We have installed sqlite3 well, as a project dependency, with node-pre-gyp generating the binary for the platform (in this case we are testing with Windows 7 64 bits)
We have a provider for Sqlite3, this is the code:
import * as sqlite3 from 'sqlite3';
import { IDatabaseProvider } from './database.provider';
export class Sqlite3DatabaseProvider implements IDatabaseProvider {
private _storage;
constructor() {
console.log('Initializing Sqlite3 Database Provider');
}
openDatabase() {
this._storage = new sqlite3.Database('v2App_sqlite3.db');
}
}
As you can notice, the line the creates a database is commented, as the app works OK like that. If I uncomment that line , we have this error:
Runtime Error
Cannot read property '_handle' of undefined
TypeError: Cannot read property '_handle' of undefined
at http://localhost:8100/build/main.js:210758:15
at Array.forEach (native)
at module.exports (http://localhost:8100/build/main.js:210757:36)
at Object.<anonymous> (http://localhost:8100/build/main.js:12580:1)
at Object.<anonymous> (http://localhost:8100/build/main.js:12873:30)
at __webpack_require__ (http://localhost:8100/build/main.js:20:30)
at Object.<anonymous> (http://localhost:8100/build/main.js:69457:11)
at Object.<anonymous> (http://localhost:8100/build/main.js:69638:30)
at __webpack_require__ (http://localhost:8100/build/main.js:20:30)
at Object.<anonymous> (http://localhost:8100/build/main.js:211548:72)
The curious of this, is that it's failing here, in the code of the set-blocking npm module:
module.exports = function (blocking) {
[process.stdout, process.stderr].forEach(function (stream) {
if (stream._handle && stream.isTTY && typeof stream._handle.setBlocking === 'function') {
stream._handle.setBlocking(blocking)
}
})
}
As stream is coming undefined ,when getting the _handle property gives the error.
But this code is only executed if I add the line that creates the sqlite3 database:
this._storage = new sqlite3.Database('v2App_sqlite3.db');
What is the relation between this module (set-blocking ) and sqlite3 ?, Why the streams are undefined when trying to create the sqlite3 database ?
Maybe as generates a file - the database - , using Node's outputStream, and still could not have been created that object - stream.
Any help?
Thanks in advance

Getting 'Dart_NewString': identifier not found on building dart-sqlite

Here is dart-sqlite: https://github.com/sam-mccall/dart-sqlite
trying to build it because I need 32bit version. Also is it possible to get it in 32bit?
I set path to dart-sdk, set path to sqlite sources and trying to build:
D:\Contrib\dart-sqlite>build
Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 16.00.40219.01 for 80x86
Copyright (C) Microsoft Corporation. All rights reserved.
dart_sqlite.cc
src\dart_sqlite.cc(42) : error C3861: 'Dart_NewString': identifier not found
src\dart_sqlite.cc(43) : error C3861: 'Dart_NewString': identifier not found
src\dart_sqlite.cc(44) : error C3861: 'Dart_NewString': identifier not found
src\dart_sqlite.cc(97) : error C3861: 'Dart_NewString': identifier not found
src\dart_sqlite.cc(121) : error C3861: 'Dart_NewString': identifier not found
src\dart_sqlite.cc(123) : error C3861: 'Dart_NewString': identifier not found
src\dart_sqlite.cc(124) : error C3861: 'Dart_NewString': identifier not found
src\dart_sqlite.cc(195) : error C3861: 'Dart_NewString': identifier not found
src\dart_sqlite.cc(229) : error C3861: 'Dart_NewString': identifier not found
src\dart_sqlite.cc(266) : error C3861: 'Dart_IsString8': identifier not found
Generating Code...
Compiling...
sqlite3.c
Generating Code...
Must I switch compiler..? or is there something I miss?
Most uses of Dart_NewString in our code have been replaced by a utility function NewString:
// Create a new Dart String object from a C String.
static Dart_Handle NewString(const char* str) {
ASSERT(str != NULL);
return Dart_NewStringFromUTF8(reinterpret_cast<const uint8_t*>(str),
strlen(str));
}
You could include this utility function in dart_sqlite, or just use Dart_NewStringFromUTF8 directly.
There may be additional problems, because the Dart executable now includes the sqlite library, as part of NSS (Network Security Services, from Mozilla), which is used to implement secure sockets in dart:io.
Just a quick look at the latest sdk header file Dart_NewString does not exist anymore. The following signatures are available, so you might need to update sam's code.
16:53:48-adam#Adams-MacBook-Air:~/dart_bleeding/dart/runtime/include
$ grep -r Dart_NewString *
dart_api.h:DART_EXPORT Dart_Handle Dart_NewStringFromCString(const char* str);
dart_api.h:DART_EXPORT Dart_Handle Dart_NewStringFromUTF8(const uint8_t* utf8_array,
dart_api.h:DART_EXPORT Dart_Handle Dart_NewStringFromUTF16(const uint16_t* utf16_array,
dart_api.h:DART_EXPORT Dart_Handle Dart_NewStringFromUTF32(const uint32_t* utf32_array,

Resources